Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit 1442d5b

Browse files
committed
fix up results
1 parent 03d0cfa commit 1442d5b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/unittest_runner/unittest_runner/run_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33

44
# Run the tests in the given file pattern and display the results to the user.
55
# Validation tests use the ValidationTestResult class to display only the short description of the test.
6+
# This also returns simplified results for the caller to use. Simplified results is a list of the form:
7+
# [{'name': 'test_name', 'result': 'PASS/FAIL/ERROR/EXPECTED_FAILURE/UNEXPECTED_SUCCESS'}, ...]
68
def run_validation_tests(file_pattern):
79
result = run_tests(file_pattern, ValidationTestResult)
810
return result.simplified_results
911

1012
# Run the tests in the given file pattern and display the results to the user.
1113
# Student tests use the standard TextTestResult class to display the test name and short description.
1214
def run_student_tests(file_pattern):
13-
return run_tests(file_pattern, unittest.TextTestResult)
15+
run_tests(file_pattern, unittest.TextTestResult)
1416

1517
def run_tests(file_pattern, resultclass):
1618
loader = unittest.TestLoader()
1719
test_suite = loader.discover('.', file_pattern)
1820
runner = unittest.TextTestRunner(verbosity=2, resultclass=resultclass)
19-
result = runner.run(test_suite)
20-
return result
21+
return runner.run(test_suite)

packages/unittest_runner/unittest_runner/validation_runner.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
from unittest import TextTestResult
33

44
class ValidationTestResult(TextTestResult):
5-
simplified_results = []
6-
5+
def __init__(self, stream, descriptions, verbosity):
6+
super(ValidationTestResult, self).__init__(stream, descriptions, verbosity)
7+
self.simplified_results = []
78

89
# The default behavior is to display the test name and short description.
910
# We want to display only the short description if it exists, otherwise just the test name.

0 commit comments

Comments
 (0)