[Piglit] [PATCH 2/2] unittests: make error messages for generator tests better
Dylan Baker
baker.dylan.c at gmail.com
Wed Apr 13 18:42:12 UTC 2016
This replaces the simple "it failed" message with the actual stderr
output when the test fails.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
unittests/generators/test_generators.py | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/unittests/generators/test_generators.py b/unittests/generators/test_generators.py
index fd34177..6e93d91 100644
--- a/unittests/generators/test_generators.py
+++ b/unittests/generators/test_generators.py
@@ -78,15 +78,17 @@ def test_generators():
"""Tester function."""
msg = ''
- try:
- with open(os.devnull, 'w') as d:
- rcode = subprocess.check_call(['python', name], stderr=d,
- stdout=d)
- except subprocess.CalledProcessError as e:
- msg = "While calling {}:\n{}".format(name, str(e))
- rcode = e.returncode
-
- nt.eq_(rcode, 0, msg)
+ with open(os.devnull, 'w') as d:
+ proc = subprocess.Popen(['python', name],
+ stderr=subprocess.PIPE,
+ stdout=d)
+ _, err = proc.communicate()
+
+ if proc.returncode != 0:
+ err = err.decode('utf-8')
+
+ raise utils.TestFailure(
+ "failed with message:\n {}".format(err))
description = 'generator: {} runs successfully'
--
2.8.0
More information about the Piglit
mailing list