Run a single test. test_name -- the name of the test Returns a TestResult. If runtests.use_junit, xml_data is a list containing each generated testsuite element.
(test_name: TestName, runtests: RunTests)
| 329 | |
| 330 | |
| 331 | def run_single_test(test_name: TestName, runtests: RunTests) -> TestResult: |
| 332 | """Run a single test. |
| 333 | |
| 334 | test_name -- the name of the test |
| 335 | |
| 336 | Returns a TestResult. |
| 337 | |
| 338 | If runtests.use_junit, xml_data is a list containing each generated |
| 339 | testsuite element. |
| 340 | """ |
| 341 | ansi = get_colors(file=sys.stderr) |
| 342 | red, reset, yellow = ansi.BOLD_RED, ansi.RESET, ansi.YELLOW |
| 343 | |
| 344 | start_time = time.perf_counter() |
| 345 | result = TestResult(test_name) |
| 346 | pgo = runtests.pgo |
| 347 | try: |
| 348 | _runtest(result, runtests) |
| 349 | except: |
| 350 | if not pgo: |
| 351 | msg = traceback.format_exc() |
| 352 | print(f"{red}test {test_name} crashed -- {msg}{reset}", |
| 353 | file=sys.stderr, flush=True) |
| 354 | result.state = State.UNCAUGHT_EXC |
| 355 | |
| 356 | sys.stdout.flush() |
| 357 | sys.stderr.flush() |
| 358 | |
| 359 | result.duration = time.perf_counter() - start_time |
| 360 | return result |
no test coverage detected
searching dependent graphs…