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

Function capsysbinary

src/_pytest/capture.py:895–908  ·  view source on GitHub ↗

Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``. The captured output is made available via ``capsysbinary.readouterr()`` method calls, which return a ``(out, err)`` namedtuple. ``out`` and ``err`` will be ``bytes`` objects.

(request: SubRequest)

Source from the content-addressed store, hash-verified

893
894@fixture
895def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes], None, None]:
896 """Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
897
898 The captured output is made available via ``capsysbinary.readouterr()``
899 method calls, which return a ``(out, err)`` namedtuple.
900 ``out`` and ``err`` will be ``bytes`` objects.
901 """
902 capman = request.config.pluginmanager.getplugin("capturemanager")
903 capture_fixture = CaptureFixture[bytes](SysCaptureBinary, request, _ispytest=True)
904 capman.set_fixture(capture_fixture)
905 capture_fixture._start()
906 yield capture_fixture
907 capture_fixture.close()
908 capman.unset_fixture()
909
910
911@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