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

Function captured_stdout

Lib/test/support/__init__.py:906–913  ·  view source on GitHub ↗

Capture the output of sys.stdout: with captured_stdout() as stdout: print("hello") self.assertEqual(stdout.getvalue(), "hello\\n")

()

Source from the content-addressed store, hash-verified

904 setattr(sys, stream_name, orig_stdout)
905
906def captured_stdout():
907 """Capture the output of sys.stdout:
908
909 with captured_stdout() as stdout:
910 print("hello")
911 self.assertEqual(stdout.getvalue(), "hello\\n")
912 """
913 return captured_output("stdout")
914
915def captured_stderr():
916 """Capture the output of sys.stderr:

Callers 15

run_mainMethod · 0.90
test_frozenMethod · 0.90
verify_tabnanny_checkMethod · 0.90
run_with_captureMethod · 0.90
test_coverageMethod · 0.90
test_coverage_ignoreMethod · 0.90
test_issue9936Method · 0.90
test_no_source_fileMethod · 0.90
test_show_codeMethod · 0.90
test_nestedMethod · 0.90

Calls 1

captured_outputFunction · 0.85

Tested by 15

run_mainMethod · 0.72
test_frozenMethod · 0.72
verify_tabnanny_checkMethod · 0.72
run_with_captureMethod · 0.72
test_coverageMethod · 0.72
test_coverage_ignoreMethod · 0.72
test_issue9936Method · 0.72
test_no_source_fileMethod · 0.72
test_show_codeMethod · 0.72
test_nestedMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…