This example shows the usage of assertXMLEqual, one of the assertions provided by PyXMLUnit.


The code for the simples test we could possibly imagine (example.py )



from xmltestcase import XMLTestCase

class TestSimpleXMLChecks(XMLTestCase):

def testAssertEqualStrings(self):
self.assertXMLEqual("<root>equal</root>", "<root>equal</root>")

def testAssertNotEqualStrings(self):
self.assertXMLNotEqual("
<root>equal</root>", "<root>not equal</root>")

if __name__ == '__main__':
unittest.main()






Running the example from the command line you should see the two tests passing.

python example.py

..
----------------------------------------------------------------------
Ran 2 tests in 0.040s

OK


The problems you may find running this simple test is that you may not have a compliant XML DOM parser installed, check available ones in http://pyxml.sourceforge.net