MCPcopy
hub / github.com/pytest-dev/pytest / test_capturing_basic_api

Method test_capturing_basic_api

testing/test_capture.py:65–92  ·  view source on GitHub ↗
(self, method)

Source from the content-addressed store, hash-verified

63class TestCaptureManager:
64 @pytest.mark.parametrize("method", ["no", "sys", "fd"])
65 def test_capturing_basic_api(self, method) -> None:
66 capouter = StdCaptureFD()
67 old = sys.stdout, sys.stderr, sys.stdin
68 try:
69 capman = CaptureManager(method)
70 capman.start_global_capturing()
71 capman.suspend_global_capture()
72 outerr = capman.read_global_capture()
73 assert outerr == ("", "")
74 capman.suspend_global_capture()
75 outerr = capman.read_global_capture()
76 assert outerr == ("", "")
77 print("hello")
78 capman.suspend_global_capture()
79 out, _err = capman.read_global_capture()
80 if method == "no":
81 assert old == (sys.stdout, sys.stderr, sys.stdin)
82 else:
83 assert not out
84 capman.resume_global_capture()
85 print("hello")
86 capman.suspend_global_capture()
87 out, _err = capman.read_global_capture()
88 if method != "no":
89 assert out == "hello\n"
90 capman.stop_global_capturing()
91 finally:
92 capouter.stop_capturing()
93
94 def test_init_capturing(self):
95 capouter = StdCaptureFD()

Callers

nothing calls this directly

Calls 8

read_global_captureMethod · 0.95
resume_global_captureMethod · 0.95
stop_global_capturingMethod · 0.95
CaptureManagerClass · 0.90
StdCaptureFDFunction · 0.85
stop_capturingMethod · 0.80

Tested by

no test coverage detected