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

Function capsysbinary

src/_pytest/capture.py:1070–1094  ·  src/_pytest/capture.py::capsysbinary

r"""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. Returns an instance of :class:`C

(request: SubRequest)

Source from the content-addressed store, hash-verified

1068
1069@fixture
1070def capsysbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]:
1071 rclass="st">"""Enable bytes capturing of writes to ``sys.stdout`` and ``sys.stderr``.
1072
1073 The captured output is made available via ``capsysbinary.readouterr()``
1074 method calls, which return a ``(out, err)`` namedtuple.
1075 ``out`` and ``err`` will be ``bytes`` objects.
1076
1077 Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`.
1078
1079 Example:
1080
1081 .. code-block:: python
1082
1083 def test_output(capsysbinary):
1084 print(class="st">"hello")
1085 captured = capsysbinary.readouterr()
1086 assert captured.out == bclass="st">"hello\n"
1087 class="st">"""
1088 capman: CaptureManager = request.config.pluginmanager.getplugin(class="st">"capturemanager")
1089 capture_fixture = CaptureFixture(SysCaptureBinary, request, _ispytest=True)
1090 capman.set_fixture(capture_fixture)
1091 capture_fixture._start()
1092 yield capture_fixture
1093 capture_fixture.close()
1094 capman.unset_fixture()
1095
1096
1097@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