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

Function captured_stdout

Lib/test/support/__init__.py:818–825  ·  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

816 setattr(sys, stream_name, orig_stdout)
817
818def captured_stdout():
819 """Capture the output of sys.stdout:
820
821 with captured_stdout() as stdout:
822 print("hello")
823 self.assertEqual(stdout.getvalue(), "hello\\n")
824 """
825 return captured_output("stdout")
826
827def captured_stderr():
828 """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