From: Patrick Steinhardt Date: Thu, 1 Aug 2019 08:08:21 +0000 (+0200) Subject: test: use XMLTestRunner output parameter X-Git-Tag: v0.13.72~57^2~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5f1715ff20824ffe098b3da9a6381ac36d9244d;p=zziplib test: use XMLTestRunner output parameter 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. --- diff --git a/test/zziptests.py b/test/zziptests.py index b065b61..12b2fc2 100644 --- a/test/zziptests.py +++ b/test/zziptests.py @@ -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)