]> granicus.if.org Git - zziplib/commitdiff
test: use XMLTestRunner output parameter
authorPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2019 08:08:21 +0000 (10:08 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2019 08:14:04 +0000 (10:14 +0200)
Instead of manually opening the output file for the XMLTestRunner one
can simply specify the output file by passing its path as "output"
parameter.

This fixes encoding issues with Python 3.

test/zziptests.py

index b065b61a53579316a9707fe32abf753f143f202d..12b2fc2cf501ec57678a8af91ab29f72bb85e9b9 100644 (file)
@@ -3558,18 +3558,14 @@ if __name__ == "__main__":
         if arg.startswith("_"): arg = arg[1:]
         if matches(method, arg):
           suite.addTest(testclass(method))
-  xmlresults = None
+
   if opt.xmlresults:
+    import xmlrunner
     if os.path.exists(opt.xmlresults):
       os.remove(opt.xmlresults)
-    xmlresults = open(opt.xmlresults, "w")
     logg.info("xml results into %s", opt.xmlresults)
-  #
-  # TextTestRunner(verbosity=opt.verbose).run(suite)
-  if xmlresults:
-    import xmlrunner
     Runner = xmlrunner.XMLTestRunner
-    Runner(xmlresults).run(suite)
+    Runner(output=opt.xmlresults).run(suite)
   else:
     Runner = unittest.TextTestRunner
     Runner(verbosity=opt.verbose).run(suite)