experimental XML output (requires unittest-xml-reporting package)
authorStefan Behnel <scoder@users.berlios.de>
Fri, 5 Mar 2010 08:56:16 +0000 (09:56 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Fri, 5 Mar 2010 08:56:16 +0000 (09:56 +0100)
runtests.py

index bdfad13f2f573c9610d763911881015b577c912e..f5958f7ea48082b10d9b4dee300bac9334076a8f 100644 (file)
@@ -724,7 +724,9 @@ if __name__ == '__main__':
                       help="display test progress, pass twice to print test names")
     parser.add_option("-T", "--ticket", dest="tickets",
                       action="append",
-                      help="a bug ticket number to run the respective test in 'tests/bugs'")
+                      help="a bug ticket number to run the respective test in 'tests/*'")
+    parser.add_option("--xml-output", dest="xml_output_dir", metavar="DIR",
+                      help="write test results in XML to directory DIR")
 
     options, cmd_args = parser.parse_args()
 
@@ -878,7 +880,20 @@ if __name__ == '__main__':
                 os.path.join(sys.prefix, 'lib', 'python'+sys.version[:3], 'test'),
                 'pyregr'))
 
-    result = unittest.TextTestRunner(verbosity=options.verbosity).run(test_suite)
+    if xml_output_dir:
+        try:
+            from xmlrunner import XMLTestRunner
+        except ImportError:
+            sys.stderr.write(
+                "Failed to import xmlrunner.XMLTestRunner, no XML output available\n")
+            xml_output_dir = None
+
+    if xml_output_dir:
+        test_runner = XMLTestRunner(output=xml_output_dir)
+    else:
+        test_runner = unittest.TextTestRunner(verbosity=options.verbosity)
+
+    result = test_runner.run(test_suite)
 
     if options.coverage:
         coverage.stop()