capture: add type annotations to CaptureFixture

It now has a str/bytes type parameter.
This commit is contained in:
Ran Benita
2020-08-09 20:15:19 +03:00
parent 8a66f0a96d
commit acc9310c17
2 changed files with 42 additions and 30 deletions

View File

@@ -22,7 +22,9 @@ from _pytest.config import ExitCode
# pylib 1.4.20.dev2 (rev 13d9af95547e)
def StdCaptureFD(out: bool = True, err: bool = True, in_: bool = True) -> MultiCapture:
def StdCaptureFD(
out: bool = True, err: bool = True, in_: bool = True
) -> MultiCapture[str]:
return capture.MultiCapture(
in_=capture.FDCapture(0) if in_ else None,
out=capture.FDCapture(1) if out else None,
@@ -30,7 +32,9 @@ def StdCaptureFD(out: bool = True, err: bool = True, in_: bool = True) -> MultiC
)
def StdCapture(out: bool = True, err: bool = True, in_: bool = True) -> MultiCapture:
def StdCapture(
out: bool = True, err: bool = True, in_: bool = True
) -> MultiCapture[str]:
return capture.MultiCapture(
in_=capture.SysCapture(0) if in_ else None,
out=capture.SysCapture(1) if out else None,
@@ -38,7 +42,9 @@ def StdCapture(out: bool = True, err: bool = True, in_: bool = True) -> MultiCap
)
def TeeStdCapture(out: bool = True, err: bool = True, in_: bool = True) -> MultiCapture:
def TeeStdCapture(
out: bool = True, err: bool = True, in_: bool = True
) -> MultiCapture[str]:
return capture.MultiCapture(
in_=capture.SysCapture(0, tee=True) if in_ else None,
out=capture.SysCapture(1, tee=True) if out else None,