@@ -57,9 +57,16 @@ def test_constructor1(self):
5757
5858 self .assertTrue ('sld' in sld_doc ._nsmap )
5959
60- expected = """<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0"/>"""
60+ expected = ["<sld:StyledLayerDescriptor" ,
61+ 'xmlns:sld="http://www.opengis.net/sld"' ,
62+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
63+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
64+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
65+ 'version="1.0.0"'
66+ ]
6167 actual = etree .tostring (sld_doc ._node , with_tail = False )
62- self .assertEqual (actual , expected .encode ('utf-8' ))
68+ for item in expected :
69+ self .assertIn (item .encode ('utf-8' ), actual )
6370
6471 sld_doc .normalize ()
6572
@@ -153,13 +160,18 @@ def test_userstyle_title1(self):
153160
154161 us ._node .remove (us ._node [2 ])
155162
156- expected = """<UserStyle xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
157- <Title>%s</Title>
158- <Abstract>A grayscale style showing the population numbers in a given geounit.</Abstract>
159- </UserStyle>""" % expected
163+ expected = [
164+ '<UserStyle' ,
165+ 'xmlns="http://www.opengis.net/sld"' ,
166+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
167+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
168+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
169+ '<Title>%s</Title>' % expected ,
170+ '<Abstract>A grayscale style showing the population numbers in a given geounit.</Abstract>'
171+ ]
160172 actual = etree .tostring (us ._node , with_tail = False )
161- self . assertEqual ( len ( actual ), len ( expected ))
162- self .assertEqual ( actual , expected .encode ('utf-8' ), "UserStyle was not serialized correctly. \n %s" % actual )
173+ for item in expected :
174+ self .assertIn ( item .encode ('utf-8' ), actual )
163175
164176 sld_doc .normalize ()
165177 self .assertFalse (sld_doc .validate ())
@@ -179,10 +191,17 @@ def test_userstyle_title2(self):
179191 us .Title = expected
180192 self .assertEqual (us .Title , expected , "UserStyle Title was '%s', not '%s'" % (us .Title , expected ,))
181193
182- expected = """<sld:UserStyle xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Title>%s</sld:Title></sld:UserStyle>""" % expected
194+ expected = [
195+ '<sld:UserStyle' ,
196+ 'xmlns:sld="http://www.opengis.net/sld"' ,
197+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
198+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
199+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
200+ '<sld:Title>%s</sld:Title>' % expected
201+ ]
183202 actual = etree .tostring (us ._node , with_tail = False )
184- self . assertEqual ( len ( actual ), len ( expected ))
185- self .assertEqual ( actual , expected .encode ('utf-8' ), "UserStyle was not serialized correctly. \n %s" % actual )
203+ for item in expected :
204+ self .assertIn ( item .encode ('utf-8' ), actual )
186205
187206 sld_doc .normalize ()
188207 self .assertFalse (sld_doc .validate ())
@@ -202,13 +221,18 @@ def test_userstyle_abstract1(self):
202221
203222 us ._node .remove (us ._node [2 ])
204223
205- expected = """<UserStyle xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
206- <Title>Population</Title>
207- <Abstract>%s</Abstract>
208- </UserStyle>""" % expected
224+ expected = [
225+ '<UserStyle' ,
226+ 'xmlns="http://www.opengis.net/sld"' ,
227+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
228+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
229+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
230+ '<Title>Population</Title>' ,
231+ '<Abstract>%s</Abstract>' % expected
232+ ]
209233 actual = etree .tostring (us ._node , with_tail = False )
210- self . assertEqual ( len ( actual ), len ( expected ))
211- self .assertEqual ( actual , expected .encode ('utf-8' ), "UserStyle was not serialized correctly. \n %s" % actual )
234+ for item in expected :
235+ self .assertIn ( item .encode ('utf-8' ), actual )
212236
213237 sld_doc .normalize ()
214238 self .assertFalse (sld_doc .validate ())
@@ -228,10 +252,17 @@ def test_userstyle_abstract2(self):
228252 us .Abstract = expected
229253 self .assertEqual (us .Abstract , expected , "UserStyle Abstract was '%s', not '%s'" % (us .Abstract , expected ,))
230254
231- expected = """<sld:UserStyle xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Abstract>%s</sld:Abstract></sld:UserStyle>""" % expected
255+ expected = [
256+ '<sld:UserStyle' ,
257+ 'xmlns:sld="http://www.opengis.net/sld"' ,
258+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
259+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
260+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
261+ '<sld:Abstract>%s</sld:Abstract>' % expected
262+ ]
232263 actual = etree .tostring (us ._node , with_tail = False )
233- self . assertEqual ( len ( actual ), len ( expected ))
234- self .assertEqual ( actual , expected .encode ('utf-8' ), "UserStyle was not serialized correctly. \n %s" % actual )
264+ for item in expected :
265+ self .assertIn ( item .encode ('utf-8' ), actual )
235266
236267 sld_doc .normalize ()
237268 self .assertFalse (sld_doc .validate ())
@@ -301,23 +332,29 @@ def test_rule_title1(self):
301332 rule .Title = expected
302333 self .assertEqual (rule .Title , expected )
303334
304- expected = """<Rule xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
305- <Title>> 999</Title>
306- <ogc:Filter>
335+ expected = [
336+ '<Rule' ,
337+ 'xmlns="http://www.opengis.net/sld"' ,
338+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
339+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
340+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
341+ '<Title>> 999</Title>' ,
342+ '''<ogc:Filter>
307343 <ogc:PropertyIsGreaterThanOrEqualTo>
308344 <ogc:PropertyName>number</ogc:PropertyName>
309345 <ogc:Literal>880</ogc:Literal>
310346 </ogc:PropertyIsGreaterThanOrEqualTo>
311- </ogc:Filter>
312- <MaxScaleDenominator>20000</MaxScaleDenominator>
313- <PolygonSymbolizer>
347+ </ogc:Filter>''' ,
348+ ' <MaxScaleDenominator>20000</MaxScaleDenominator>' ,
349+ ''' <PolygonSymbolizer>
314350 <Fill>
315351 <CssParameter name="fill">#252525</CssParameter>
316352 </Fill>
317- </PolygonSymbolizer>
318- </Rule>"""
353+ </PolygonSymbolizer>'''
354+ ]
319355 actual = etree .tostring (rule ._node , with_tail = False )
320- self .assertEqual (actual , expected .encode ('utf-8' ), actual )
356+ for item in expected :
357+ self .assertIn (item .encode ('utf-8' ), actual )
321358
322359 sld_doc .normalize ()
323360 self .assertTrue (sld_doc .validate ())
@@ -338,9 +375,17 @@ def test_rule_title2(self):
338375 rule .Title = expected
339376 self .assertEqual (rule .Title , expected )
340377
341- expected = """<sld:Rule xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Title>> 999</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer></sld:Rule>"""
378+ expected = [
379+ '<sld:Rule' ,
380+ 'xmlns:sld="http://www.opengis.net/sld"' ,
381+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
382+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
383+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
384+ '<sld:Title>> 999</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer>'
385+ ]
342386 actual = etree .tostring (rule ._node , with_tail = False )
343- self .assertEqual (actual , expected .encode ('utf-8' ), actual )
387+ for item in expected :
388+ self .assertIn (item .encode ('utf-8' ), actual )
344389
345390 sld_doc .normalize ()
346391 self .assertTrue (sld_doc .validate ())
@@ -541,9 +586,17 @@ def test_filter_and(self):
541586
542587 rule .Filter = filter1 + filter2
543588
544- expected = """<sld:Rule xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:And><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsLessThanOrEqualTo></ogc:And></ogc:Filter></sld:Rule>"""
589+ expected = [
590+ '<sld:Rule' ,
591+ 'xmlns:sld="http://www.opengis.net/sld"' ,
592+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
593+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
594+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
595+ '<sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:And><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:PropertyIsLessThanOrEqualTo><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsLessThanOrEqualTo></ogc:And></ogc:Filter>'
596+ ]
545597 actual = etree .tostring (rule ._node , with_tail = False )
546- self .assertEqual (actual , expected .encode ('utf-8' ))
598+ for item in expected :
599+ self .assertIn (item .encode ('utf-8' ), actual )
547600
548601 sld_doc .normalize ()
549602 self .assertTrue (sld_doc .validate ())
@@ -570,9 +623,17 @@ def test_filter_or(self):
570623
571624 rule .Filter = filter1 | filter2
572625
573- expected = """<sld:Rule xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:Or><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:PropertyIsLessThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsLessThan></ogc:Or></ogc:Filter></sld:Rule>"""
626+ expected = [
627+ '<sld:Rule' ,
628+ 'xmlns:sld="http://www.opengis.net/sld"' ,
629+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
630+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
631+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
632+ '<sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:Or><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:PropertyIsLessThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsLessThan></ogc:Or></ogc:Filter>'
633+ ]
574634 actual = etree .tostring (rule ._node , with_tail = False )
575- self .assertEqual (actual , expected .encode ('utf-8' ))
635+ for item in expected :
636+ self .assertIn (item .encode ('utf-8' ), actual )
576637
577638 sld_doc .normalize ()
578639 self .assertTrue (sld_doc .validate ())
@@ -604,9 +665,17 @@ def test_filter_and_or(self):
604665
605666 rule .Filter = filter1 + (filter2 | filter3 )
606667
607- expected = """<sld:Rule xmlns:sld="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc"><sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:And><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:Or><ogc:PropertyIsLessThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsLessThan><ogc:PropertyIsEqualTo><ogc:PropertyName>value</ogc:PropertyName><ogc:Literal>yes</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:And></ogc:Filter></sld:Rule>"""
668+ expected = [
669+ '<sld:Rule' ,
670+ 'xmlns:sld="http://www.opengis.net/sld"' ,
671+ 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' ,
672+ 'xmlns:xlink="http://www.w3.org/1999/xlink"' ,
673+ 'xmlns:ogc="http://www.opengis.net/ogc"' ,
674+ '<sld:Title>test rule</sld:Title><sld:PointSymbolizer><sld:Graphic><sld:Mark><sld:WellKnownName>square</sld:WellKnownName><sld:Fill><sld:CssParameter name="fill">#ff0000</sld:CssParameter></sld:Fill></sld:Mark></sld:Graphic></sld:PointSymbolizer><ogc:Filter><ogc:And><ogc:PropertyIsGreaterThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>10</ogc:Literal></ogc:PropertyIsGreaterThan><ogc:Or><ogc:PropertyIsLessThan><ogc:PropertyName>number</ogc:PropertyName><ogc:Literal>-10</ogc:Literal></ogc:PropertyIsLessThan><ogc:PropertyIsEqualTo><ogc:PropertyName>value</ogc:PropertyName><ogc:Literal>yes</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Or></ogc:And></ogc:Filter>'
675+ ]
608676 actual = etree .tostring (rule ._node , with_tail = False , pretty_print = False )
609- self .assertEqual (actual , expected .encode ('utf-8' ))
677+ for item in expected :
678+ self .assertIn (item .encode ('utf-8' ), actual )
610679
611680 sld_doc .normalize ()
612681 self .assertTrue (sld_doc .validate ())
@@ -756,7 +825,7 @@ def test_scale_denominators(self):
756825
757826 sld_doc .normalize ()
758827 self .assertTrue (sld_doc .validate ())
759-
828+
760829
761830if __name__ == '__main__' :
762831 unittest .main ()
0 commit comments