Fix check_untyped_defs errors in capture

This commit is contained in:
Ran Benita 2019-09-14 00:20:24 +03:00
parent 0267b25c66
commit 1787bffda0
2 changed files with 9 additions and 7 deletions

View File

@ -12,6 +12,7 @@ from tempfile import TemporaryFile
import pytest
from _pytest.compat import CaptureIO
from _pytest.fixtures import FixtureRequest
patchsysdict = {0: "stdin", 1: "stdout", 2: "stderr"}
@ -241,13 +242,12 @@ class CaptureManager:
capture_fixtures = {"capfd", "capfdbinary", "capsys", "capsysbinary"}
def _ensure_only_one_capture_fixture(request, name):
fixtures = set(request.fixturenames) & capture_fixtures - {name}
def _ensure_only_one_capture_fixture(request: FixtureRequest, name):
fixtures = sorted(set(request.fixturenames) & capture_fixtures - {name})
if fixtures:
fixtures = sorted(fixtures)
fixtures = fixtures[0] if len(fixtures) == 1 else fixtures
arg = fixtures[0] if len(fixtures) == 1 else fixtures
raise request.raiseerror(
"cannot use {} and {} at the same time".format(fixtures, name)
"cannot use {} and {} at the same time".format(arg, name)
)

View File

@ -6,6 +6,8 @@ import subprocess
import sys
import textwrap
from io import UnsupportedOperation
from typing import List
from typing import TextIO
import py
@ -857,8 +859,8 @@ def tmpfile(testdir):
@needsosdup
def test_dupfile(tmpfile):
flist = []
def test_dupfile(tmpfile) -> None:
flist = [] # type: List[TextIO]
for i in range(5):
nf = capture.safe_text_dupfile(tmpfile, "wb")
assert nf != tmpfile