Fix check_untyped_defs errors in capture
This commit is contained in:
parent
0267b25c66
commit
1787bffda0
|
@ -12,6 +12,7 @@ from tempfile import TemporaryFile
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from _pytest.compat import CaptureIO
|
from _pytest.compat import CaptureIO
|
||||||
|
from _pytest.fixtures import FixtureRequest
|
||||||
|
|
||||||
patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
|
patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
|
||||||
|
|
||||||
|
@ -241,13 +242,12 @@ class CaptureManager:
|
||||||
capture_fixtures = {"capfd", "capfdbinary", "capsys", "capsysbinary"}
|
capture_fixtures = {"capfd", "capfdbinary", "capsys", "capsysbinary"}
|
||||||
|
|
||||||
|
|
||||||
def _ensure_only_one_capture_fixture(request, name):
|
def _ensure_only_one_capture_fixture(request: FixtureRequest, name):
|
||||||
fixtures = set(request.fixturenames) & capture_fixtures - {name}
|
fixtures = sorted(set(request.fixturenames) & capture_fixtures - {name})
|
||||||
if fixtures:
|
if fixtures:
|
||||||
fixtures = sorted(fixtures)
|
arg = fixtures[0] if len(fixtures) == 1 else fixtures
|
||||||
fixtures = fixtures[0] if len(fixtures) == 1 else fixtures
|
|
||||||
raise request.raiseerror(
|
raise request.raiseerror(
|
||||||
"cannot use {} and {} at the same time".format(fixtures, name)
|
"cannot use {} and {} at the same time".format(arg, name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
from io import UnsupportedOperation
|
from io import UnsupportedOperation
|
||||||
|
from typing import List
|
||||||
|
from typing import TextIO
|
||||||
|
|
||||||
import py
|
import py
|
||||||
|
|
||||||
|
@ -857,8 +859,8 @@ def tmpfile(testdir):
|
||||||
|
|
||||||
|
|
||||||
@needsosdup
|
@needsosdup
|
||||||
def test_dupfile(tmpfile):
|
def test_dupfile(tmpfile) -> None:
|
||||||
flist = []
|
flist = [] # type: List[TextIO]
|
||||||
for i in range(5):
|
for i in range(5):
|
||||||
nf = capture.safe_text_dupfile(tmpfile, "wb")
|
nf = capture.safe_text_dupfile(tmpfile, "wb")
|
||||||
assert nf != tmpfile
|
assert nf != tmpfile
|
||||||
|
|
Loading…
Reference in New Issue