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

Function worker_process

Lib/test/libregrtest/worker.py:83–120  ·  view source on GitHub ↗
(worker_json: StrJSON)

Source from the content-addressed store, hash-verified

81
82
83def worker_process(worker_json: StrJSON) -> NoReturn:
84 runtests = WorkerRunTests.from_json(worker_json)
85 test_name = runtests.tests[0]
86 match_tests: TestFilter = runtests.match_tests
87 json_file: JsonFile = runtests.json_file
88
89 setup_test_dir(runtests.test_dir)
90 setup_process()
91
92 if runtests.rerun:
93 if match_tests:
94 matching = "matching: " + ", ".join(pattern for pattern, result in match_tests if result)
95 print(f"Re-running {test_name} in verbose mode ({matching})", flush=True)
96 else:
97 print(f"Re-running {test_name} in verbose mode", flush=True)
98
99 result = run_single_test(test_name, runtests)
100 if runtests.coverage:
101 if "test.cov" in sys.modules: # imported by -Xpresite=
102 result.covered_lines = list(sys.modules["test.cov"].coverage)
103 elif not Py_DEBUG:
104 print(
105 "Gathering coverage in worker processes requires --with-pydebug",
106 flush=True,
107 )
108 else:
109 raise LookupError(
110 "`test.cov` not found in sys.modules but coverage wanted"
111 )
112
113 if json_file.file_type == JsonFileType.STDOUT:
114 print()
115 result.write_json_into(sys.stdout)
116 else:
117 with json_file.open('w', encoding='utf-8') as json_fp:
118 result.write_json_into(json_fp)
119
120 sys.exit(0)
121
122
123def main() -> NoReturn:

Callers 1

mainFunction · 0.85

Calls 9

setup_processFunction · 0.85
run_single_testFunction · 0.85
listClass · 0.85
write_json_intoMethod · 0.80
setup_test_dirFunction · 0.70
from_jsonMethod · 0.45
joinMethod · 0.45
openMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…