From 9d5c35e057374e3846dcbfda7337ae3e868e39b3 Mon Sep 17 00:00:00 2001 From: "Ivan A. Melnikov" Date: Fri, 17 Jan 2014 15:32:56 +0400 Subject: [PATCH] Minor cleanup in test_examples - check process exit code instead of stderr emptiness; - in case of failure include stderr and stdout of example into exception message. Change-Id: I3957810c8ac0621bafa4eda85e089071d96c794e --- taskflow/tests/test_examples.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/taskflow/tests/test_examples.py b/taskflow/tests/test_examples.py index f526b94c..c9b95b42 100644 --- a/taskflow/tests/test_examples.py +++ b/taskflow/tests/test_examples.py @@ -52,10 +52,18 @@ def run_example(name): obj = subprocess.Popen([sys.executable, path], stdout=subprocess.PIPE, stderr=subprocess.PIPE) output = obj.communicate() - if output[1]: - raise RuntimeError('Example wrote to stderr:\n%s' - % output[1].decode()) - return output[0].decode() + stdout = output[0].decode() + stderr = output[1].decode() + + rc = obj.wait() + if rc != 0: + raise RuntimeError('Example %s failed, return code=%s\n' + '<<>>\n%s' + '<<>>\n' + '<<>>\n%s' + '<<>>' + % (name, rc, stdout, stderr)) + return stdout def expected_output_path(name): @@ -67,7 +75,7 @@ def list_examples(): for filename in os.listdir(examples_dir): name, ext = os.path.splitext(filename) if ext == ".py" and 'utils' not in name.lower(): - yield filename[:-len(ext)] + yield name class ExamplesTestCase(taskflow.test.TestCase):