From c5f1715ff20824ffe098b3da9a6381ac36d9244d Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 1 Aug 2019 10:08:21 +0200 Subject: [PATCH] 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. --- test/zziptests.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) 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) -- 2.40.0