@@ -160,20 +160,22 @@ def test_raising_unittest_skiptest_during_collection_is_deprecated(
160160def test_hookproxy_warnings_for_fspath (pytestconfig , tmp_path , request ):
161161 path = legacy_path (tmp_path )
162162
163- with pytest .warns (
164- PytestDeprecationWarning ,
165- match = "path : py.path.local is deprecated, please use fspath : pathlib.Path" ,
166- ):
163+ PATH_WARN_MATCH = r".*path: py\.path\.local\) argument is deprecated, please use \(fspath: pathlib\.Path.*"
164+
165+ with pytest .warns (PytestDeprecationWarning , match = PATH_WARN_MATCH ) as r :
167166 pytestconfig .hook .pytest_ignore_collect (
168167 config = pytestconfig , path = path , fspath = tmp_path
169168 )
170- with pytest .warns (
171- PytestDeprecationWarning ,
172- match = "path : py.path.local is deprecated, please use fspath : pathlib.Path" ,
173- ):
169+ (record ,) = r
170+ assert record .filename == __file__
171+ assert record .lineno == 166
172+
173+ with pytest .warns (PytestDeprecationWarning , match = PATH_WARN_MATCH ) as r :
174174 request .node .ihook .pytest_ignore_collect (
175175 config = pytestconfig , path = path , fspath = tmp_path
176176 )
177-
177+ (record ,) = r
178+ assert record .filename == __file__
179+ assert record .lineno == 174
178180 pytestconfig .hook .pytest_ignore_collect (config = pytestconfig , fspath = tmp_path )
179181 request .node .ihook .pytest_ignore_collect (config = pytestconfig , fspath = tmp_path )
0 commit comments