MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_capturing_basic_api

Method test_capturing_basic_api

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

Source from the content-addressed store, hash-verified

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