From 42c0acfc44f195584ad020dcc02cf0bcdcfdc46b Mon Sep 17 00:00:00 2001 From: Lucas Meneghel Rodrigues Date: Tue, 27 Oct 2015 11:15:30 -0200 Subject: [PATCH] test.py: Return test output only if subprocess succeeded The current code will try to print the output of a subprocess.Popen().communicate() call even if that call raised an exception and that output is None. Let's fix this problem by only printing the output if it's not None. Signed-off-by: Lucas Meneghel Rodrigues --- test.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test.py b/test.py index 78e39bd1cd..9a796d8d37 100755 --- a/test.py +++ b/test.py @@ -149,9 +149,10 @@ if __name__ == "__main__": print_status('TIMED OUT\n') else: print_status(' with error code {code}\n'.format(code=proc.returncode)) - print('=== stdout START ===') - print(str(out, encoding='UTF-8')) - print('=== stdout END ===') + if out is not None: + print('=== stdout START ===') + print(str(out, encoding='UTF-8')) + print('=== stdout END ===') all_ok = False else: print_status('%s PASSED %s' % (prefix, path))