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

Function _captured_script

Lib/test/test__interpreters.py:21–30  ·  view source on GitHub ↗
(script)

Source from the content-addressed store, hash-verified

19# helpers
20
21def _captured_script(script):
22 r, w = os.pipe()
23 indented = script.replace('\n', '\n ')
24 wrapped = dedent(f"""
25 import contextlib
26 with open({w}, 'w', encoding="utf-8") as spipe:
27 with contextlib.redirect_stdout(spipe):
28 {indented}
29 """)
30 return wrapped, open(r, encoding="utf-8")
31
32
33def _run_output(interp, request):

Callers 6

_run_outputFunction · 0.70
test_successMethod · 0.70
test_in_threadMethod · 0.70
test_create_threadMethod · 0.70
test_os_execMethod · 0.70

Calls 4

dedentFunction · 0.90
openFunction · 0.50
pipeMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…