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

Method test_simple_resume_suspend

testing/test_capture.py:1096–1126  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1094 assert stmp == data2
1095
1096 def test_simple_resume_suspend(self) -> None:
1097 with saved_fd(1):
1098 cap = capture.FDCapture(1)
1099 cap.start()
1100 data = b"hello"
1101 os.write(1, data)
1102 sys.stdout.write("whatever")
1103 s = cap.snap()
1104 assert s == "hellowhatever"
1105 cap.suspend()
1106 os.write(1, b"world")
1107 sys.stdout.write("qlwkej")
1108 assert not cap.snap()
1109 cap.resume()
1110 os.write(1, b"but now")
1111 sys.stdout.write(" yes\n")
1112 s = cap.snap()
1113 assert s == "but now yes\n"
1114 cap.suspend()
1115 cap.done()
1116 with pytest.raises(AssertionError):
1117 cap.suspend()
1118
1119 assert repr(cap) == (
1120 f"<FDCapture 1 oldfd={cap.targetfd_save} _state='done' tmpfile={cap.tmpfile!r}>"
1121 )
1122 # Should not crash with missing "_old".
1123 assert isinstance(cap.syscapture, capture.SysCapture)
1124 assert repr(cap.syscapture) == (
1125 f"<SysCapture stdout _old=<UNSET> _state='done' tmpfile={cap.syscapture.tmpfile!r}>"
1126 )
1127
1128 def test_capfd_sys_stdout_mode(self, capfd) -> None:
1129 assert "b" not in sys.stdout.mode

Callers

nothing calls this directly

Calls 7

snapMethod · 0.95
saved_fdFunction · 0.85
startMethod · 0.45
writeMethod · 0.45
suspendMethod · 0.45
resumeMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected