Skip to content

Commit 663eaee

Browse files
committed
_CaptureMethod
1 parent c00baa5 commit 663eaee

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/_pytest/capture.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717
import pytest
1818
from _pytest.compat import CaptureAndPassthroughIO
1919
from _pytest.compat import CaptureIO
20+
from _pytest.compat import TYPE_CHECKING
2021
from _pytest.config import Config
2122
from _pytest.fixtures import FixtureRequest
2223

24+
if TYPE_CHECKING:
25+
from typing_extensions import Literal
26+
27+
_CaptureMethod = Literal["fd", "sys", "no", "tee-sys"]
28+
2329
patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
2430

2531

@@ -66,7 +72,7 @@ def pytest_load_initial_conftests(early_config: Config):
6672
sys.stderr.write(err)
6773

6874

69-
def _get_multicapture(method: str) -> "MultiCapture":
75+
def _get_multicapture(method: "_CaptureMethod") -> "MultiCapture":
7076
if method == "fd":
7177
return MultiCapture(out=True, err=True, Capture=FDCapture)
7278
elif method == "sys":
@@ -91,7 +97,7 @@ class CaptureManager:
9197
case special handling is needed to ensure the fixtures take precedence over the global capture.
9298
"""
9399

94-
def __init__(self, method) -> None:
100+
def __init__(self, method: "_CaptureMethod") -> None:
95101
self._method = method
96102
self._global_capturing = None
97103
self._capture_fixture = None # type: Optional[CaptureFixture]

0 commit comments

Comments
 (0)