|
1 | 1 | import signal |
2 | 2 | import textwrap |
3 | 3 |
|
| 4 | +import mypy.version |
| 5 | +from packaging.version import Version |
4 | 6 | import pexpect |
5 | 7 | import pytest |
6 | 8 |
|
7 | 9 |
|
8 | | -PYTEST_VERSION = tuple(int(v) for v in pytest.__version__.split(".")[:2]) |
| 10 | +MYPY_VERSION = Version(mypy.version.__version__) |
| 11 | +PYTEST_VERSION = Version(pytest.__version__) |
9 | 12 |
|
10 | 13 |
|
11 | 14 | @pytest.fixture( |
@@ -275,13 +278,18 @@ def pytest_configure(config): |
275 | 278 | assert result.ret == 0 |
276 | 279 |
|
277 | 280 |
|
| 281 | +@pytest.mark.xfail( |
| 282 | + Version("0.971") <= MYPY_VERSION, |
| 283 | + raises=AssertionError, |
| 284 | + reason="https://github.com/python/mypy/issues/13701", |
| 285 | +) |
278 | 286 | @pytest.mark.parametrize( |
279 | 287 | "module_name", |
280 | 288 | [ |
281 | 289 | pytest.param( |
282 | 290 | "__init__", |
283 | 291 | marks=pytest.mark.xfail( |
284 | | - (3, 10) <= PYTEST_VERSION < (6, 2), |
| 292 | + Version("3.10") <= PYTEST_VERSION < Version("6.2"), |
285 | 293 | raises=AssertionError, |
286 | 294 | reason="https://github.com/pytest-dev/pytest/issues/8016", |
287 | 295 | ), |
@@ -398,7 +406,7 @@ def pyfunc(x: int) -> str: |
398 | 406 | ) |
399 | 407 |
|
400 | 408 | num_tests = 2 |
401 | | - if module_name == "__init__" and (3, 10) <= PYTEST_VERSION < (6, 2): |
| 409 | + if module_name == "__init__" and Version("3.10") <= PYTEST_VERSION < Version("6.2"): |
402 | 410 | # https://github.com/pytest-dev/pytest/issues/8016 |
403 | 411 | # Pytest had a bug where it assumed only a Package would have a basename of |
404 | 412 | # __init__.py. In this test, Pytest mistakes MypyFile for a Package and |
@@ -443,7 +451,9 @@ def _expect_success(): |
443 | 451 | try: |
444 | 452 | child.expect(str(num_tests) + " passed") |
445 | 453 | except pexpect.exceptions.TIMEOUT: |
446 | | - if module_name == "__init__" and (6, 0) <= PYTEST_VERSION < (6, 2): |
| 454 | + if module_name == "__init__" and ( |
| 455 | + Version("6.0") <= PYTEST_VERSION < Version("6.2") |
| 456 | + ): |
447 | 457 | # MypyItems hit the __init__.py bug too when --looponfail |
448 | 458 | # re-collects them after the failing file is modified. |
449 | 459 | # Unlike MypyFile, MypyItem is not a Collector, so this used |
|
0 commit comments