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

Function capfd

src/_pytest/capture.py:912–925  ·  view source on GitHub ↗

Enable text capturing of writes to file descriptors ``1`` and ``2``. The captured output is made available via ``capfd.readouterr()`` method calls, which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will be ``text`` objects.

(request: SubRequest)

Source from the content-addressed store, hash-verified

910
911@fixture
912def capfd(request: SubRequest) -> Generator[CaptureFixture[str], None, None]:
913 """Enable text capturing of writes to file descriptors ``1`` and ``2``.
914
915 The captured output is made available via ``capfd.readouterr()`` method
916 calls, which return a ``(out, err)`` namedtuple.
917 ``out`` and ``err`` will be ``text`` objects.
918 """
919 capman = request.config.pluginmanager.getplugin("capturemanager")
920 capture_fixture = CaptureFixture[str](FDCapture, request, _ispytest=True)
921 capman.set_fixture(capture_fixture)
922 capture_fixture._start()
923 yield capture_fixture
924 capture_fixture.close()
925 capman.unset_fixture()
926
927
928@fixture

Callers

nothing calls this directly

Calls 5

getpluginMethod · 0.80
set_fixtureMethod · 0.80
_startMethod · 0.80
unset_fixtureMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected