import sys, StringIO, string import unittest import webserv_example_heavy_sub # A comparison function for case-insenstive sorting. def mycmpfunc(arg1, arg2): return cmp(string.lower(arg1), string.lower(arg2)) class XmlTest(unittest.TestCase): def test_import_export1(self): inFile = file('test1_in.xml', 'r') inContent = inFile.read() inFile.close() doc = webserv_example_heavy_sub.parseString(inContent) outFile = StringIO.StringIO() outFile.write('\n') doc.export(outFile, 0) outContent = outFile.getvalue() outFile.close() self.failUnless(inContent == outContent) # make the test suite. def suite(): loader = unittest.TestLoader() # Change the test method prefix: test --> trial. #loader.testMethodPrefix = 'trial' # Change the comparison function that determines the order of tests. #loader.sortTestMethodsUsing = mycmpfunc testsuite = loader.loadTestsFromTestCase(XmlTest) return testsuite # Make the test suite; run the tests. def test_main(): testsuite = suite() runner = unittest.TextTestRunner(sys.stdout, verbosity=2) result = runner.run(testsuite) if __name__ == "__main__": test_main()