(self, method)
| 58 | class 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() |
nothing calls this directly
no test coverage detected