Run tests from a unittest.TestSuite-derived class.
(suite)
| 76 | suite._tests = newtests |
| 77 | |
| 78 | def _run_suite(suite): |
| 79 | """Run tests from a unittest.TestSuite-derived class.""" |
| 80 | runner = get_test_runner(sys.stdout, |
| 81 | verbosity=support.verbose, |
| 82 | capture_output=(support.junit_xml_list is not None)) |
| 83 | |
| 84 | result = runner.run(suite) |
| 85 | |
| 86 | if support.junit_xml_list is not None: |
| 87 | import xml.etree.ElementTree as ET |
| 88 | xml_elem = result.get_xml_element() |
| 89 | xml_str = ET.tostring(xml_elem).decode('ascii') |
| 90 | support.junit_xml_list.append(xml_str) |
| 91 | |
| 92 | if not result.testsRun and not result.skipped and not result.errors: |
| 93 | raise support.TestDidNotRun |
| 94 | if not result.wasSuccessful(): |
| 95 | stats = TestStats.from_unittest(result) |
| 96 | if len(result.errors) == 1 and not result.failures: |
| 97 | err = result.errors[0][1] |
| 98 | elif len(result.failures) == 1 and not result.errors: |
| 99 | err = result.failures[0][1] |
| 100 | else: |
| 101 | err = "multiple errors occurred" |
| 102 | if not support.verbose: err += "; run in verbose mode for details" |
| 103 | errors = [(str(tc), exc_str) for tc, exc_str in result.errors] |
| 104 | failures = [(str(tc), exc_str) for tc, exc_str in result.failures] |
| 105 | raise support.TestFailedWithDetails(err, errors, failures, stats=stats) |
| 106 | return result |
| 107 | |
| 108 | |
| 109 | def regrtest_runner(result: TestResult, test_func, runtests: RunTests) -> None: |
no test coverage detected
searching dependent graphs…