From 81f6b3960374ffe28d84454b44f6b4c4adb86b30 Mon Sep 17 00:00:00 2001 From: Aurélien Bompard Date: Jun 22 2022 09:21:10 +0000 Subject: Make the tests outputs more readable Signed-off-by: Aurélien Bompard --- diff --git a/tests/helpers/common.py b/tests/helpers/common.py index 87d62e4..afbe09c 100755 --- a/tests/helpers/common.py +++ b/tests/helpers/common.py @@ -486,8 +486,9 @@ basicConstraints = CA:false""" % {'certdir': os.path.join(self.testdir, return self.run_and_collect([self.pycmd, exe], env) def run_and_collect(self, cmd, env): - p = subprocess.Popen(cmd, env=env, - stdout=subprocess.PIPE, stderr=self.stderr) + p = subprocess.Popen( + cmd, env=env, universal_newlines=True, + stdout=subprocess.PIPE, stderr=self.stderr) results = [] for line in p.stdout: line = line[:-1] # Strip newline diff --git a/tests/helpers/control.py b/tests/helpers/control.py index 001e279..dd2b104 100644 --- a/tests/helpers/control.py +++ b/tests/helpers/control.py @@ -3,6 +3,7 @@ from __future__ import print_function import sys +from traceback import print_exception class TC(object): @@ -37,6 +38,7 @@ class TC(object): if exc is None and not self.should_fail: TC.output_method(TC.prefix + 'done') elif not self.should_fail: + print_exception(exc) TC.output_method(TC.prefix + 'fail:' + repr(exc)) sys.exit(1) elif not exc: @@ -80,8 +82,8 @@ class TC(object): case done: ('done',) case fail: ('fail', 'some error') """ - if line.startswith(TC.prefix.encode('utf-8')): - return tuple(line[len(TC.prefix):].split(b':')) + if line.startswith(TC.prefix): + return tuple(line[len(TC.prefix):].split(':')) else: return None