Skip to content

Commit bb643e6

Browse files
authored
Remove support for pytest 6.x (#151)
Pytest 7 was released over two years ago, and this repository no longer tests against pytest 6. It should be safe to assume that projects aren't relying on pytest 6 anymore. fixes: #150
1 parent 3995a96 commit bb643e6

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

pytest_mypy_plugins/collect.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import yaml
2424
from _pytest.config.argparsing import Parser
2525
from _pytest.nodes import Node
26-
from packaging.version import Version
2726

2827
from pytest_mypy_plugins import utils
2928

@@ -108,9 +107,7 @@ class YamlTestFile(pytest.File):
108107
def collect(self) -> Iterator["YamlTestItem"]:
109108
from pytest_mypy_plugins.item import YamlTestItem
110109

111-
# To support both Pytest 6.x and 7.x
112-
path = getattr(self, "path", None) or getattr(self, "fspath")
113-
parsed_file = yaml.load(stream=path.read_text("utf8"), Loader=SafeLineLoader)
110+
parsed_file = yaml.load(stream=self.path.read_text("utf8"), Loader=SafeLineLoader)
114111
if parsed_file is None:
115112
return
116113

@@ -174,19 +171,10 @@ def _eval_skip(self, skip_if: str) -> bool:
174171
return eval(skip_if, {"sys": sys, "os": os, "pytest": pytest, "platform": platform})
175172

176173

177-
if Version(pytest.__version__) >= Version("7.0.0rc1"):
178-
179-
def pytest_collect_file(file_path: pathlib.Path, parent: Node) -> Optional[YamlTestFile]:
180-
if file_path.suffix in {".yaml", ".yml"} and file_path.name.startswith(("test-", "test_")):
181-
return YamlTestFile.from_parent(parent, path=file_path, fspath=None)
182-
return None
183-
184-
else:
185-
186-
def pytest_collect_file(path: py.path.local, parent: Node) -> Optional[YamlTestFile]: # type: ignore[misc]
187-
if path.ext in {".yaml", ".yml"} and path.basename.startswith(("test-", "test_")):
188-
return YamlTestFile.from_parent(parent, fspath=path)
189-
return None
174+
def pytest_collect_file(file_path: pathlib.Path, parent: Node) -> Optional[YamlTestFile]:
175+
if file_path.suffix in {".yaml", ".yml"} and file_path.name.startswith(("test-", "test_")):
176+
return YamlTestFile.from_parent(parent, path=file_path, fspath=None)
177+
return None
190178

191179

192180
def pytest_addoption(parser: Parser) -> None:

pytest_mypy_plugins/item.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,5 @@ def repr_failure(
466466
else:
467467
return super().repr_failure(excinfo, style="native")
468468

469-
def reportinfo(self) -> Tuple[Union[py.path.local, Path, str], Optional[int], str]:
470-
# To support both Pytest 6.x and 7.x
471-
path = getattr(self, "path", None) or getattr(self, "fspath")
472-
assert path
473-
return path, None, self.name
469+
def reportinfo(self) -> Tuple[Union[Path, str], Optional[int], str]:
470+
return self.path, None, self.name

0 commit comments

Comments
 (0)