r"""Enable bytes 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 ``byte`` objects. Returns an instance of :class:`CaptureFix
(request: SubRequest)
| 1124 | |
| 1125 | @fixture |
| 1126 | def capfdbinary(request: SubRequest) -> Generator[CaptureFixture[bytes]]: |
| 1127 | r"""Enable bytes capturing of writes to file descriptors ``1`` and ``2``. |
| 1128 | |
| 1129 | The captured output is made available via ``capfd.readouterr()`` method |
| 1130 | calls, which return a ``(out, err)`` namedtuple. |
| 1131 | ``out`` and ``err`` will be ``byte`` objects. |
| 1132 | |
| 1133 | Returns an instance of :class:`CaptureFixture[bytes] <pytest.CaptureFixture>`. |
| 1134 | |
| 1135 | Example: |
| 1136 | |
| 1137 | .. code-block:: python |
| 1138 | |
| 1139 | def test_system_echo(capfdbinary): |
| 1140 | os.system('echo "hello"') |
| 1141 | captured = capfdbinary.readouterr() |
| 1142 | assert captured.out == b"hello\n" |
| 1143 | |
| 1144 | """ |
| 1145 | capman: CaptureManager = request.config.pluginmanager.getplugin("capturemanager") |
| 1146 | capture_fixture = CaptureFixture(FDCaptureBinary, request, _ispytest=True) |
| 1147 | capman.set_fixture(capture_fixture) |
| 1148 | capture_fixture._start() |
| 1149 | yield capture_fixture |
| 1150 | capture_fixture.close() |
| 1151 | capman.unset_fixture() |
nothing calls this directly
no test coverage detected