fix #8371: fix stack-level
This commit is contained in:
parent
bad1963697
commit
deb5b5bd96
|
@ -49,7 +49,8 @@ class PathAwareHookProxy:
|
||||||
warnings.warn(
|
warnings.warn(
|
||||||
HOOK_LEGACY_PATH_ARG.format(
|
HOOK_LEGACY_PATH_ARG.format(
|
||||||
pylib_path_arg=fspath_var, pathlib_path_arg=path_var
|
pylib_path_arg=fspath_var, pathlib_path_arg=path_var
|
||||||
)
|
),
|
||||||
|
stacklevel=2,
|
||||||
)
|
)
|
||||||
path_value, fspath_value = _imply_path(path_value, fspath_value)
|
path_value, fspath_value = _imply_path(path_value, fspath_value)
|
||||||
kw[path_var] = path_value
|
kw[path_var] = path_value
|
||||||
|
|
|
@ -160,20 +160,22 @@ def test_raising_unittest_skiptest_during_collection_is_deprecated(
|
||||||
def test_hookproxy_warnings_for_fspath(pytestconfig, tmp_path, request):
|
def test_hookproxy_warnings_for_fspath(pytestconfig, tmp_path, request):
|
||||||
path = legacy_path(tmp_path)
|
path = legacy_path(tmp_path)
|
||||||
|
|
||||||
with pytest.warns(
|
PATH_WARN_MATCH = r".*path: py\.path\.local\) argument is deprecated, please use \(fspath: pathlib\.Path.*"
|
||||||
PytestDeprecationWarning,
|
|
||||||
match="path : py.path.local is deprecated, please use fspath : pathlib.Path",
|
with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
|
||||||
):
|
|
||||||
pytestconfig.hook.pytest_ignore_collect(
|
pytestconfig.hook.pytest_ignore_collect(
|
||||||
config=pytestconfig, path=path, fspath=tmp_path
|
config=pytestconfig, path=path, fspath=tmp_path
|
||||||
)
|
)
|
||||||
with pytest.warns(
|
(record,) = r
|
||||||
PytestDeprecationWarning,
|
assert record.filename == __file__
|
||||||
match="path : py.path.local is deprecated, please use fspath : pathlib.Path",
|
assert record.lineno == 166
|
||||||
):
|
|
||||||
|
with pytest.warns(PytestDeprecationWarning, match=PATH_WARN_MATCH) as r:
|
||||||
request.node.ihook.pytest_ignore_collect(
|
request.node.ihook.pytest_ignore_collect(
|
||||||
config=pytestconfig, path=path, fspath=tmp_path
|
config=pytestconfig, path=path, fspath=tmp_path
|
||||||
)
|
)
|
||||||
|
(record,) = r
|
||||||
|
assert record.filename == __file__
|
||||||
|
assert record.lineno == 174
|
||||||
pytestconfig.hook.pytest_ignore_collect(config=pytestconfig, fspath=tmp_path)
|
pytestconfig.hook.pytest_ignore_collect(config=pytestconfig, fspath=tmp_path)
|
||||||
request.node.ihook.pytest_ignore_collect(config=pytestconfig, fspath=tmp_path)
|
request.node.ihook.pytest_ignore_collect(config=pytestconfig, fspath=tmp_path)
|
||||||
|
|
Loading…
Reference in New Issue