def run_tests(suites, config): test_runner = PrettyTestRunner(config) start_time = time.time() for suite in suites: if suite.countTestCases() == 0: continue log_dir = os.path.join(config.logs_path, 'test') ensure_dir(log_dir) log_filename = os.path.join(log_dir, '%s.log' % (get_suite_name(suite),)) with open(log_filename, 'w') as logfile: test_runner.run(suite, logfile) seconds_elapsed = time.time() - start_time all_tests = sum(r.testsRun for r in test_runner.results) successes = sum(r.testsPassed for r in test_runner.results) errors = sum(r.testsErrors for r in test_runner.results) failures = sum(r.testsFailed for r in test_runner.results) print('\nFinished in %f s; %s%d/%d successes%s, %s%d/%d errors%s, %s%d/%d failures%s\n' % (seconds_elapsed, COLOR_GREEN if successes == all_tests else COLOR_YELLOW, successes, all_tests, COLOR_DEFAULT, COLOR_RED if errors else COLOR_GREEN, errors, all_tests, COLOR_DEFAULT, COLOR_RED if failures else COLOR_GREEN, failures, all_tests, COLOR_DEFAULT)) return test_runner.results
def run_tests(suites, config): has_error = False test_runner = PrettyTestRunner(config) start_time = time.time() for suite in suites: if suite.countTestCases() == 0: continue log_dir = os.path.join(config.logs_path, 'test') ensure_dir(log_dir) log_filename = os.path.join(log_dir, '%s.log' % (get_suite_name(suite), )) with open(log_filename, 'w') as logfile: res = test_runner.run(suite, logfile) if not res.wasSuccessful(): has_error = True seconds_elapsed = time.time() - start_time all_tests = sum(r.testsRun for r in test_runner.results) successes = sum(r.testsPassed for r in test_runner.results) errors = sum(r.testsErrors for r in test_runner.results) failures = sum(r.testsFailed for r in test_runner.results) print( '\nFinished in %f s; %s%d/%d successes%s, %s%d/%d errors%s, %s%d/%d failures%s\n' % (seconds_elapsed, COLOR_GREEN if successes == all_tests else COLOR_YELLOW, successes, all_tests, COLOR_DEFAULT, COLOR_RED if errors else COLOR_GREEN, errors, all_tests, COLOR_DEFAULT, COLOR_RED if failures else COLOR_GREEN, failures, all_tests, COLOR_DEFAULT)) if has_error: for r in test_runner.results: print(r.errorSummary(log_root=config.target_logs_path)) raise SystemError("Some tests failed, inspect log for details")