commit 847d8a80deb20f6973b0e466cc52ffad90c5d831 Author: Damian Johnson atagar@torproject.org Date: Tue Mar 3 08:56:33 2015 -0800
No need for a 'if suite' check
We can just return prematurely. No need to hide everything else behind a conditional. --- run_tests.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/run_tests.py b/run_tests.py index 876162d..3af6d31 100755 --- a/run_tests.py +++ b/run_tests.py @@ -457,29 +457,27 @@ def _run_test(args, test_class, output_filters, logging_buffer):
println(label, STATUS, NO_NL)
- suite = None try: suite = unittest.TestLoader().loadTestsFromName(test_class) except: println(' failed (%0.2fs)' % (time.time() - start_time), ERROR) + return None
test_results = StringIO() - run_result = None - - if suite: - run_result = unittest.TextTestRunner(test_results, verbosity=2).run(suite) - if args.verbose: - println(test.output.apply_filters(test_results.getvalue(), *output_filters)) - elif not run_result.failures and not run_result.errors: - println(' success (%0.2fs)' % (time.time() - start_time), SUCCESS) + run_result = unittest.TextTestRunner(test_results, verbosity=2).run(suite) + + if args.verbose: + println(test.output.apply_filters(test_results.getvalue(), *output_filters)) + elif not run_result.failures and not run_result.errors: + println(' success (%0.2fs)' % (time.time() - start_time), SUCCESS) + else: + if args.quiet: + println(label, STATUS, NO_NL, STDERR) + println(' failed (%0.2fs)' % (time.time() - start_time), ERROR, STDERR) + println(test.output.apply_filters(test_results.getvalue(), *output_filters), STDERR) else: - if args.quiet: - println(label, STATUS, NO_NL, STDERR) - println(' failed (%0.2fs)' % (time.time() - start_time), ERROR, STDERR) - println(test.output.apply_filters(test_results.getvalue(), *output_filters), STDERR) - else: - println(' failed (%0.2fs)' % (time.time() - start_time), ERROR) - println(test.output.apply_filters(test_results.getvalue(), *output_filters), NO_NL) + println(' failed (%0.2fs)' % (time.time() - start_time), ERROR) + println(test.output.apply_filters(test_results.getvalue(), *output_filters), NO_NL)
test.output.print_logging(logging_buffer)