capture: factor out _get_multicapture (#6788)

Ref: https://github.com/pytest-dev/pytest/pull/6671#issuecomment-588408992
This commit is contained in:
Daniel Hahler
2020-02-22 23:39:20 +01:00
committed by GitHub
parent 1d5a0ef284
commit 706ea86bba
2 changed files with 29 additions and 13 deletions

View File

@@ -14,7 +14,9 @@ from typing import TextIO
import pytest
from _pytest import capture
from _pytest.capture import _get_multicapture
from _pytest.capture import CaptureManager
from _pytest.capture import MultiCapture
from _pytest.config import ExitCode
# note: py.io capture tests where copied from
@@ -1563,3 +1565,10 @@ def test_encodedfile_writelines(tmpfile: BinaryIO) -> None:
tmpfile.close()
with pytest.raises(ValueError):
ef.read()
def test__get_multicapture() -> None:
assert isinstance(_get_multicapture("fd"), MultiCapture)
pytest.raises(ValueError, _get_multicapture, "unknown").match(
r"^unknown capturing method: 'unknown'"
)