MCPcopy Index your code
hub / github.com/python/cpython / run_single_test

Function run_single_test

Lib/test/libregrtest/single.py:331–360  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

329
330
331def 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

Callers 2

run_testMethod · 0.85
worker_processFunction · 0.85

Calls 4

get_colorsFunction · 0.90
_runtestFunction · 0.85
TestResultClass · 0.70
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…