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)
| 1068 | |
| 1069 | @fixture |
| 1070 | def 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 |
nothing calls this directly
no test coverage detected