From 2e5cf1cc789908ab4856c84a99d7d1120f84e694 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 28 Oct 2019 12:34:40 +0100 Subject: [PATCH] Fix order of format args with warning --- src/_pytest/pathlib.py | 2 +- testing/test_tmpdir.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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()