Skip to content

Commit 00ad341

Browse files
committed
Require Pytest 6+
1 parent af3b814 commit 00ad341

File tree

4 files changed

+9
-54
lines changed

4 files changed

+9
-54
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"attrs>=19.0",
3434
"filelock>=3.0",
3535
"mypy>=1.0",
36-
"pytest>=5.0",
36+
"pytest>=6.0",
3737
]
3838

3939
[project.entry-points.pytest11]

src/pytest_mypy.py

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import attr
1111
from filelock import FileLock # type: ignore
1212
import mypy.api
13-
import pytest # type: ignore
13+
import pytest
1414

1515

1616
PYTEST_MAJOR_VERSION = int(pytest.__version__.partition(".")[0])
@@ -141,12 +141,6 @@ def pytest_collect_file(path, parent): # type: ignore
141141
class MypyFile(pytest.File):
142142
"""A File that Mypy will run on."""
143143

144-
@classmethod
145-
def from_parent(cls, *args, **kwargs):
146-
"""Override from_parent for compatibility."""
147-
# pytest.File.from_parent did not exist before pytest 5.4.
148-
return getattr(super(), "from_parent", cls)(*args, **kwargs)
149-
150144
def collect(self):
151145
"""Create a MypyFileItem for the File."""
152146
yield MypyFileItem.from_parent(parent=self, name=nodeid_name)
@@ -169,19 +163,6 @@ def __init__(self, *args, **kwargs):
169163
super().__init__(*args, **kwargs)
170164
self.add_marker(self.MARKER)
171165

172-
def collect(self):
173-
"""
174-
Partially work around https://github.com/pytest-dev/pytest/issues/8016
175-
for pytest < 6.0 with --looponfail.
176-
"""
177-
yield self
178-
179-
@classmethod
180-
def from_parent(cls, *args, **kwargs):
181-
"""Override from_parent for compatibility."""
182-
# pytest.Item.from_parent did not exist before pytest 5.4.
183-
return getattr(super(), "from_parent", cls)(*args, **kwargs)
184-
185166
def repr_failure(self, excinfo):
186167
"""
187168
Unwrap mypy errors so we get a clean error message without the
@@ -213,7 +194,7 @@ def reportinfo(self):
213194
return (
214195
self.fspath,
215196
None,
216-
self.config.invocation_dir.bestrelpath(self.fspath),
197+
str(Path(str(self.fspath)).relative_to(self.config.invocation_params.dir)),
217198
)
218199

219200

tests/test_pytest_mypy.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -540,30 +540,6 @@ def _break():
540540
child.kill(signal.SIGTERM)
541541

542542

543-
def test_mypy_item_collect(testdir, xdist_args):
544-
"""Ensure coverage for a 3.10<=pytest<6.0 workaround."""
545-
testdir.makepyfile(
546-
"""
547-
def test_mypy_item_collect(request):
548-
plugin = request.config.pluginmanager.getplugin("mypy")
549-
mypy_items = [
550-
item
551-
for item in request.session.items
552-
if isinstance(item, plugin.MypyItem)
553-
]
554-
assert mypy_items
555-
for mypy_item in mypy_items:
556-
assert all(item is mypy_item for item in mypy_item.collect())
557-
""",
558-
)
559-
result = testdir.runpytest_subprocess("--mypy", *xdist_args)
560-
test_count = 1
561-
mypy_file_checks = 1
562-
mypy_status_check = 1
563-
result.assert_outcomes(passed=test_count + mypy_file_checks + mypy_status_check)
564-
assert result.ret == pytest.ExitCode.OK
565-
566-
567543
def test_mypy_results_from_mypy_with_opts():
568544
"""MypyResults.from_mypy respects passed options."""
569545
mypy_results = pytest_mypy.MypyResults.from_mypy([], opts=["--version"])

tox.ini

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
minversion = 4.4
44
isolated_build = true
55
envlist =
6-
py37-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x}
7-
py38-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
8-
py39-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
6+
py37-pytest{6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x}
7+
py38-pytest{6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
8+
py39-pytest{6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
99
py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
1010
py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
1111
py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
@@ -14,18 +14,16 @@ envlist =
1414

1515
[gh-actions]
1616
python =
17-
3.7: py37-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x}
18-
3.8: py38-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}, publish, static
19-
3.9: py39-pytest{5.0, 5.x, 6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
17+
3.7: py37-pytest{6.0, 6.x, 7.0, 7.x}-mypy{1.0, 1.x}
18+
3.8: py38-pytest{6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}, publish, static
19+
3.9: py39-pytest{6.0, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
2020
3.10: py310-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
2121
3.11: py311-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
2222
3.12: py312-pytest{6.2, 6.x, 7.0, 7.x, 8.0, 8.x}-mypy{1.0, 1.x}
2323

2424
[testenv]
2525
constrain_package_deps = true
2626
deps =
27-
pytest5.0: pytest ~= 5.0.0
28-
pytest5.x: pytest ~= 5.0
2927
pytest6.0: pytest ~= 6.0.0
3028
pytest6.2: pytest ~= 6.2.0
3129
pytest6.x: pytest ~= 6.0

0 commit comments

Comments
 (0)