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

Function captured_stdin

Lib/test/support/__init__.py:924–934  ·  view source on GitHub ↗

Capture the input to sys.stdin: with captured_stdin() as stdin: stdin.write('hello\\n') stdin.seek(0) # call test code that consumes from sys.stdin captured = input() self.assertEqual(captured, "hello")

()

Source from the content-addressed store, hash-verified

922 return captured_output("stderr")
923
924def captured_stdin():
925 """Capture the input to sys.stdin:
926
927 with captured_stdin() as stdin:
928 stdin.write('hello\\n')
929 stdin.seek(0)
930 # call test code that consumes from sys.stdin
931 captured = input()
932 self.assertEqual(captured, "hello")
933 """
934 return captured_output("stdin")
935
936
937def gc_collect():

Callers 1

run_cliMethod · 0.90

Calls 1

captured_outputFunction · 0.85

Tested by 1

run_cliMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…