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

Method test_simple_resume_suspend

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

Source from the content-addressed store, hash-verified

1013 assert stmp == data2
1014
1015 def test_simple_resume_suspend(self) -> None:
1016 with saved_fd(1):
1017 cap = capture.FDCapture(1)
1018 cap.start()
1019 data = b"hello"
1020 os.write(1, data)
1021 sys.stdout.write("whatever")
1022 s = cap.snap()
1023 assert s == "hellowhatever"
1024 cap.suspend()
1025 os.write(1, b"world")
1026 sys.stdout.write("qlwkej")
1027 assert not cap.snap()
1028 cap.resume()
1029 os.write(1, b"but now")
1030 sys.stdout.write(" yes\n")
1031 s = cap.snap()
1032 assert s == "but now yes\n"
1033 cap.suspend()
1034 cap.done()
1035 pytest.raises(AssertionError, cap.suspend)
1036
1037 assert repr(cap) == (
1038 "<FDCapture 1 oldfd={} _state='done' tmpfile={!r}>".format(
1039 cap.targetfd_save, cap.tmpfile
1040 )
1041 )
1042 # Should not crash with missing "_old".
1043 assert repr(cap.syscapture) == (
1044 "<SysCapture stdout _old=<UNSET> _state='done' tmpfile={!r}>".format(
1045 cap.syscapture.tmpfile
1046 )
1047 )
1048
1049 def test_capfd_sys_stdout_mode(self, capfd) -> None:
1050 assert "b" not in sys.stdout.mode

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected