Skip to content

Commit

Permalink
Merge pull request #140 from dmtucker/mypy13701
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtucker committed Sep 25, 2022
2 parents 9710ab4 + 3e6c6e5 commit 7575b64
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/test_pytest_mypy.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import signal
import textwrap

import mypy.version
from packaging.version import Version
import pexpect
import pytest


PYTEST_VERSION = tuple(int(v) for v in pytest.__version__.split(".")[:2])
MYPY_VERSION = Version(mypy.version.__version__)
PYTEST_VERSION = Version(pytest.__version__)


@pytest.fixture(
Expand Down Expand Up @@ -275,13 +278,18 @@ def pytest_configure(config):
assert result.ret == 0


@pytest.mark.xfail(
Version("0.971") <= MYPY_VERSION,
raises=AssertionError,
reason="https://github.com/python/mypy/issues/13701",
)
@pytest.mark.parametrize(
"module_name",
[
pytest.param(
"__init__",
marks=pytest.mark.xfail(
(3, 10) <= PYTEST_VERSION < (6, 2),
Version("3.10") <= PYTEST_VERSION < Version("6.2"),
raises=AssertionError,
reason="https://github.com/pytest-dev/pytest/issues/8016",
),
Expand Down Expand Up @@ -398,7 +406,7 @@ def pyfunc(x: int) -> str:
)

num_tests = 2
if module_name == "__init__" and (3, 10) <= PYTEST_VERSION < (6, 2):
if module_name == "__init__" and Version("3.10") <= PYTEST_VERSION < Version("6.2"):
# https://github.com/pytest-dev/pytest/issues/8016
# Pytest had a bug where it assumed only a Package would have a basename of
# __init__.py. In this test, Pytest mistakes MypyFile for a Package and
Expand Down Expand Up @@ -443,7 +451,9 @@ def _expect_success():
try:
child.expect(str(num_tests) + " passed")
except pexpect.exceptions.TIMEOUT:
if module_name == "__init__" and (6, 0) <= PYTEST_VERSION < (6, 2):
if module_name == "__init__" and (
Version("6.0") <= PYTEST_VERSION < Version("6.2")
):
# MypyItems hit the __init__.py bug too when --looponfail
# re-collects them after the failing file is modified.
# Unlike MypyFile, MypyItem is not a Collector, so this used
Expand Down
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,16 @@ deps =
mypy0.81: mypy >= 0.810, < 0.820
mypy0.8x: mypy >= 0.800, < 0.900
mypy0.90: mypy >= 0.900, < 0.910
mypy0.91: mypy >= 0.910, < 0.920
mypy0.92: mypy >= 0.920, < 0.930
mypy0.93: mypy >= 0.930, < 0.940
mypy0.94: mypy >= 0.940, < 0.950
mypy0.95: mypy >= 0.950, < 0.960
mypy0.96: mypy >= 0.960, < 0.970
mypy0.97: mypy >= 0.970, < 0.980
mypy0.9x: mypy >= 0.900, <= 0.999

packaging ~= 21.3
pexpect ~= 4.8.0
pytest-cov ~= 2.10
pytest-randomly ~= 3.4
Expand Down

0 comments on commit 7575b64

Please sign in to comment.