From 3e6c6e552130204a5cc12db848b7f2b5a256edc4 Mon Sep 17 00:00:00 2001 From: David Tucker Date: Sun, 25 Sep 2022 08:16:38 -0700 Subject: [PATCH] Xfail python/mypy#13701 --- tests/test_pytest_mypy.py | 18 ++++++++++++++---- tox.ini | 8 ++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/tests/test_pytest_mypy.py b/tests/test_pytest_mypy.py index 10b2a0d..60c07f5 100644 --- a/tests/test_pytest_mypy.py +++ b/tests/test_pytest_mypy.py @@ -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( @@ -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", ), @@ -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 @@ -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 diff --git a/tox.ini b/tox.ini index 211ad8f..c9ea697 100644 --- a/tox.ini +++ b/tox.ini @@ -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