MCPcopy Create free account
hub / github.com/pytest-dev/pytest / test_hookproxy_warnings_for_pathlib

Function test_hookproxy_warnings_for_pathlib

testing/deprecated_test.py:163–190  ·  view source on GitHub ↗
(tmp_path, hooktype, request)

Source from the content-addressed store, hash-verified

161
162@pytest.mark.parametrize("hooktype", ["hook", "ihook"])
163def test_hookproxy_warnings_for_pathlib(tmp_path, hooktype, request):
164 path = legacy_path(tmp_path)
165
166 PATH_WARN_MATCH = r".*path: py\.path\.local\) argument is deprecated, please use \(collection_path: pathlib\.Path.*"
167 if hooktype == "ihook":
168 hooks = request.node.ihook
169 else:
170 hooks = request.config.hook
171
172 with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
173 l1 = sys._getframe().f_lineno
174 hooks.pytest_ignore_collect(
175 config=request.config, path=path, collection_path=tmp_path
176 )
177 l2 = sys._getframe().f_lineno
178
179 (record,) = r
180 assert record.filename == __file__
181 assert l1 < record.lineno < l2
182
183 hooks.pytest_ignore_collect(config=request.config, collection_path=tmp_path)
184
185 # Passing entirely *different* paths is an outright error.
186 with pytest.raises(ValueError, match=r"path.*fspath.*need to be equal"):
187 with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
188 hooks.pytest_ignore_collect(
189 config=request.config, path=path, collection_path=Path("/bla/bla")
190 )
191
192
193def test_warns_none_is_deprecated():

Callers

nothing calls this directly

Calls 1

legacy_pathFunction · 0.90

Tested by

no test coverage detected