File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ Paths appearing in error messages are now correct in case the current working directory has
2+ changed since the start of the session.
Original file line number Diff line number Diff line change @@ -51,3 +51,30 @@ class FakeSession:
5151
5252 outside = py .path .local ("/outside" )
5353 assert nodes ._check_initialpaths_for_relpath (FakeSession , outside ) is None
54+
55+
56+ def test_failure_with_changed_cwd (testdir ):
57+ """
58+ Test failure lines should use absolute paths if cwd has changed since
59+ invocation, so the path is correct (#6428).
60+ """
61+ p = testdir .makepyfile (
62+ """
63+ import os
64+ import pytest
65+
66+ @pytest.fixture
67+ def private_dir():
68+ out_dir = 'ddd'
69+ os.mkdir(out_dir)
70+ old_dir = os.getcwd()
71+ os.chdir(out_dir)
72+ yield out_dir
73+ os.chdir(old_dir)
74+
75+ def test_show_wrong_path(private_dir):
76+ assert False
77+ """
78+ )
79+ result = testdir .runpytest ()
80+ result .stdout .fnmatch_lines ([str (p ) + ":*: AssertionError" , "*1 failed in *" ])
You can’t perform that action at this time.
0 commit comments