MCPcopy Index your code
hub / github.com/RustPython/RustPython / run_single_test

Function run_single_test

Lib/test/libregrtest/single.py:332–361  ·  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

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

Callers 2

run_testMethod · 0.85
worker_processFunction · 0.85

Calls 5

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

Tested by

no test coverage detected