diff --git a/src/_pytest/pathlib.py b/src/_pytest/pathlib.py index bd76fac6b..8d25b21dd 100644 --- a/src/_pytest/pathlib.py +++ b/src/_pytest/pathlib.py @@ -72,7 +72,7 @@ def on_rm_rf_error(func, path: str, exc, *, start_path: Path) -> bool: warnings.warn( PytestWarning( "(rm_rf) unknown function {} when removing {}:\n{}: {}".format( - path, func, exctype, excvalue + func, path, exctype, excvalue ) ) ) diff --git a/testing/test_tmpdir.py b/testing/test_tmpdir.py index 2433d6145..29b6db947 100644 --- a/testing/test_tmpdir.py +++ b/testing/test_tmpdir.py @@ -388,7 +388,10 @@ class TestRmRf: assert not on_rm_rf_error(None, str(fn), exc_info, start_path=tmp_path) # unknown function - with pytest.warns(pytest.PytestWarning): + with pytest.warns( + pytest.PytestWarning, + match=r"^\(rm_rf\) unknown function None when removing .*foo.txt:\nNone: ", + ): exc_info = (None, PermissionError(), None) on_rm_rf_error(None, str(fn), exc_info, start_path=tmp_path) assert fn.is_file()