From 31633d0d3651a9313438d219105787bf0ac2e92b Mon Sep 17 00:00:00 2001 From: Dirk Thomas Date: Fri, 6 Jul 2012 02:04:36 +0000 Subject: [PATCH] improved output for unit test errors and failures (#3992) --- tools/rosunit/src/rosunit/baretest.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/rosunit/src/rosunit/baretest.py b/tools/rosunit/src/rosunit/baretest.py index dbe123cd..3a914f2f 100644 --- a/tools/rosunit/src/rosunit/baretest.py +++ b/tools/rosunit/src/rosunit/baretest.py @@ -505,6 +505,17 @@ def print_runner_summary(runner_results, junit_results, runner_name='ROSUNIT'): print buff.getvalue() +def _format_errors(errors): + formatted = [] + for e in errors: + if '_testMethodName' in e[0].__dict__: + formatted.append(e[0]._testMethodName) + elif 'description' in e[0].__dict__: + formatted.append('%s: %s\n' % (str(e[0].description), str(e[1]))) + else: + formatted.append(str(e[0].__dict__)) + return formatted + def print_unittest_summary(result): """ Print summary of python unittest result to stdout @@ -517,7 +528,7 @@ def print_unittest_summary(result): else: buff.write(" * RESULT: FAIL\n") buff.write(" * TESTS: %s\n"%result.testsRun) - buff.write(" * ERRORS: %s [%s]\n"%(len(result.errors), ', '.join([e[0]._testMethodName for e in result.errors]))) - buff.write(" * FAILURES: %s [%s]\n"%(len(result.failures), ','.join([e[0]._testMethodName for e in result.failures]))) + buff.write(" * ERRORS: %s [%s]\n"%(len(result.errors), ', '.join(_format_errors(result.errors)))) + buff.write(" * FAILURES: %s [%s]\n"%(len(result.failures), ', '.join(_format_errors(result.failures)))) print buff.getvalue()