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

Function capteesys

src/_pytest/capture.py:1035–1066  ·  src/_pytest/capture.py::capteesys

r"""Enable simultaneous text capturing and pass-through of writes to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``. The captured output is made available via ``capteesys.readouterr()`` method calls, which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will

(request: SubRequest)

Source from the content-addressed store, hash-verified

1033
1034@fixture
1035def capteesys(request: SubRequest) -> Generator[CaptureFixture[str]]:
1036 rclass="st">"""Enable simultaneous text capturing and pass-through of writes
1037 to ``sys.stdout`` and ``sys.stderr`` as defined by ``--capture=``.
1038
1039
1040 The captured output is made available via ``capteesys.readouterr()`` method
1041 calls, which return a ``(out, err)`` namedtuple.
1042 ``out`` and ``err`` will be ``text`` objects.
1043
1044 The output is also passed-through, allowing it to be class="st">"live-printed",
1045 reported, or both as defined by ``--capture=``.
1046
1047 Returns an instance of :class:`CaptureFixture[str] <pytest.CaptureFixture>`.
1048
1049 Example:
1050
1051 .. code-block:: python
1052
1053 def test_output(capteesys):
1054 print(class="st">"hello")
1055 captured = capteesys.readouterr()
1056 assert captured.out == class="st">"hello\n"
1057 class="st">"""
1058 capman: CaptureManager = request.config.pluginmanager.getplugin(class="st">"capturemanager")
1059 capture_fixture = CaptureFixture(
1060 SysCapture, request, config=dict(tee=True), _ispytest=True
1061 )
1062 capman.set_fixture(capture_fixture)
1063 capture_fixture._start()
1064 yield capture_fixture
1065 capture_fixture.close()
1066 capman.unset_fixture()
1067
1068
1069@fixture

Callers

nothing calls this directly

Calls 6

_startMethod · 0.95
closeMethod · 0.95
CaptureFixtureClass · 0.85
getpluginMethod · 0.80
set_fixtureMethod · 0.80
unset_fixtureMethod · 0.80

Tested by

no test coverage detected