Skip to content

Commit 1787bff

Browse files
committed
Fix check_untyped_defs errors in capture
1 parent 0267b25 commit 1787bff

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/_pytest/capture.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import pytest
1414
from _pytest.compat import CaptureIO
15+
from _pytest.fixtures import FixtureRequest
1516

1617
patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
1718

@@ -241,13 +242,12 @@ def pytest_internalerror(self, excinfo):
241242
capture_fixtures = {"capfd", "capfdbinary", "capsys", "capsysbinary"}
242243

243244

244-
def _ensure_only_one_capture_fixture(request, name):
245-
fixtures = set(request.fixturenames) & capture_fixtures - {name}
245+
def _ensure_only_one_capture_fixture(request: FixtureRequest, name):
246+
fixtures = sorted(set(request.fixturenames) & capture_fixtures - {name})
246247
if fixtures:
247-
fixtures = sorted(fixtures)
248-
fixtures = fixtures[0] if len(fixtures) == 1 else fixtures
248+
arg = fixtures[0] if len(fixtures) == 1 else fixtures
249249
raise request.raiseerror(
250-
"cannot use {} and {} at the same time".format(fixtures, name)
250+
"cannot use {} and {} at the same time".format(arg, name)
251251
)
252252

253253

testing/test_capture.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import sys
77
import textwrap
88
from io import UnsupportedOperation
9+
from typing import List
10+
from typing import TextIO
911

1012
import py
1113

@@ -857,8 +859,8 @@ def tmpfile(testdir):
857859

858860

859861
@needsosdup
860-
def test_dupfile(tmpfile):
861-
flist = []
862+
def test_dupfile(tmpfile) -> None:
863+
flist = [] # type: List[TextIO]
862864
for i in range(5):
863865
nf = capture.safe_text_dupfile(tmpfile, "wb")
864866
assert nf != tmpfile

0 commit comments

Comments
 (0)