Skip to content

Commit f01f8c3

Browse files
Fix deprecation warning for pytest>=5.4.0 (#25)
* Fix deprecation warning for pytest>=5.4.0 * fixup! Fix deprecation warning for pytest>=5.4.0 * Bump pytest * Remove compatiblity
1 parent 05d98a7 commit f01f8c3

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

pytest_mypy_plugins/collect.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,9 @@ def collect(self) -> Iterator["YamlTestItem"]:
8686

8787
skip = self._eval_skip(str(raw_test.get("skip", "False")))
8888
if not skip:
89-
yield YamlTestItem(
89+
yield YamlTestItem.from_parent(
90+
self,
9091
name=test_name,
91-
collector=self,
92-
config=self.config,
9392
files=test_files,
9493
starting_lineno=starting_lineno,
9594
environment_variables=extra_environment_variables,
@@ -105,7 +104,7 @@ def _eval_skip(self, skip_if: str) -> bool:
105104

106105
def pytest_collect_file(path: LocalPath, parent: Node) -> Optional[YamlTestFile]:
107106
if path.ext in {".yaml", ".yml"} and path.basename.startswith(("test-", "test_")):
108-
return YamlTestFile(path, parent=parent, config=parent.config)
107+
return YamlTestFile.from_parent(parent, fspath=path)
109108
return None
110109

111110

pytest_mypy_plugins/item.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ class YamlTestItem(pytest.Item):
9696
def __init__(
9797
self,
9898
name: str,
99-
collector: YamlTestFile,
100-
config: Config,
99+
parent: Optional[YamlTestFile] = None,
100+
config: Optional[Config] = None,
101+
*,
101102
files: List[File],
102103
starting_lineno: int,
103104
expected_output_lines: List[str],
@@ -106,7 +107,7 @@ def __init__(
106107
mypy_config: str,
107108
parsed_test_data: Dict[str, Any],
108109
) -> None:
109-
super().__init__(name, collector, config)
110+
super().__init__(name, parent, config)
110111
self.files = files
111112
self.environment_variables = environment_variables
112113
self.disable_cache = disable_cache
@@ -117,9 +118,9 @@ def __init__(
117118
self.same_process = self.config.option.mypy_same_process
118119

119120
# config parameters
120-
self.root_directory = config.option.mypy_testing_base
121-
if config.option.mypy_ini_file:
122-
self.base_ini_fpath = os.path.abspath(config.option.mypy_ini_file)
121+
self.root_directory = self.config.option.mypy_testing_base
122+
if self.config.option.mypy_ini_file:
123+
self.base_ini_fpath = os.path.abspath(self.config.option.mypy_ini_file)
123124
else:
124125
self.base_ini_fpath = None
125126
self.incremental_cache_dir = os.path.join(self.root_directory, ".mypy_cache")

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
with open("README.md", "r") as f:
44
readme = f.read()
55

6-
dependencies = ["pytest", "mypy>=0.730", "decorator", "pyyaml"]
6+
dependencies = ["pytest>=5.4.0", "mypy>=0.730", "decorator", "pyyaml"]
77

88
setup(
99
name="pytest-mypy-plugins",

0 commit comments

Comments
 (0)