@@ -17,15 +17,13 @@ class XmlTestMixin(object):
1717
1818 One may want to extends unittest.TestCase itself, and then uses this
1919 mixin class to add specific XML assertions.
20-
2120 """
2221 default_partial_tag = 'partialTest'
2322
2423 def assertXmlDocument (self , data ):
2524 """Asserts `data` is an XML document and returns it.
2625
2726 Assertion and XML parsing using lxml.
28-
2927 """
3028 # no assertion yet
3129 try :
@@ -57,7 +55,6 @@ def assertXmlNamespace(self, node, prefix, uri):
5755 """Asserts `node` declares namespace `uri` using `prefix`.
5856
5957 One can use this method on element node.
60-
6158 """
6259 self .assertIn (prefix , node .nsmap )
6360 self .assertEqual (node .nsmap .get (prefix ), uri )
@@ -67,7 +64,6 @@ def assertXmlHasAttribute(self, node, attribute, **kwargs):
6764
6865 Argument `attribute` must be the attribute's name, with
6966 namespace's prefix (notation 'ns:att' and not '{uri}att').
70-
7167 """
7268 assert attribute in node .attrib
7369
@@ -79,9 +75,7 @@ def assertXmlHasAttribute(self, node, attribute, **kwargs):
7975 kwargs .get ('expected_values' ))
8076
8177 def assertXmlNode (self , node , ** kwargs ):
82- """Asserts `node` is an element node with expected tag and value.
83-
84- """
78+ """Asserts `node` is an element node with expected tag and value."""
8579 # Assert `node` is an element node and not None or a string or
8680 # anything like this
8781 self .assertIsInstance (node , etree ._Element )
@@ -189,15 +183,17 @@ def assertXmlValidXSchema(self, node, xschema=None, filename=None,
189183
190184 if xschema is None and filename is not None :
191185 with open (filename , 'r' ) as xschema_file :
192- schema = etree .XMLSchema (etree .XML (xschema_file .read ().encode (encoding )))
186+ schema = etree .XMLSchema (
187+ etree .XML (xschema_file .read ().encode (encoding )))
193188
194189 if schema is None :
195190 raise ValueError ('No valid XMLSchema given.' )
196191
197192 if not schema .validate (node ):
198193 self .fail (schema .error_log .last_error )
199194
200- def assertXmlValidRelaxNG (self , node , relaxng = None , filename = None , encoding = 'utf-8' ):
195+ def assertXmlValidRelaxNG (self , node , relaxng = None , filename = None ,
196+ encoding = 'utf-8' ):
201197 """Asserts XML node is valid according to the given RelaxNG."""
202198 schema = None
203199
@@ -208,7 +204,8 @@ def assertXmlValidRelaxNG(self, node, relaxng=None, filename=None, encoding='utf
208204
209205 if relaxng is None and filename is not None :
210206 with open (filename , 'r' ) as relaxng_file :
211- schema = etree .RelaxNG (etree .XML (relaxng_file .read ().encode (encoding )))
207+ schema = etree .RelaxNG (
208+ etree .XML (relaxng_file .read ().encode (encoding )))
212209
213210 if schema is None :
214211 raise ValueError ('No valid RelaxNG given.' )
@@ -225,7 +222,6 @@ def assertXmlEquivalentOutputs(self, data, expected):
225222 check than just a kind of output.
226223
227224 See LXMLOutputChecker documentation for more information.
228-
229225 """
230226 checker = LXMLOutputChecker ()
231227
@@ -239,10 +235,9 @@ def assertXmlEquivalentOutputs(self, data, expected):
239235class XmlTestCase (unittest .TestCase , XmlTestMixin ):
240236 """XML test case for unit test using python unittest built-in package.
241237
242- One can extends this class for his test case and use helpful assertion
243- method .
238+ One can extends this class for their test cases and use helpful assertion
239+ methods .
244240
245241 XML parsing uses python lxml.etree.
246-
247242 """
248243 pass
0 commit comments