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 @@ -58,3 +58,30 @@ class FakeSession:
58
58
59
59
outside = py .path .local ("/outside" )
60
60
assert nodes ._check_initialpaths_for_relpath (FakeSession , outside ) is None
61
+
62
+
63
+ def test_failure_with_changed_cwd (testdir ):
64
+ """
65
+ Test failure lines should use absolute paths if cwd has changed since
66
+ invocation, so the path is correct (#6428).
67
+ """
68
+ p = testdir .makepyfile (
69
+ """
70
+ import os
71
+ import pytest
72
+
73
+ @pytest.fixture
74
+ def private_dir():
75
+ out_dir = 'ddd'
76
+ os.mkdir(out_dir)
77
+ old_dir = os.getcwd()
78
+ os.chdir(out_dir)
79
+ yield out_dir
80
+ os.chdir(old_dir)
81
+
82
+ def test_show_wrong_path(private_dir):
83
+ assert False
84
+ """
85
+ )
86
+ result = testdir .runpytest ()
87
+ result .stdout .fnmatch_lines ([str (p ) + ":*: AssertionError" , "*1 failed in *" ])
You can’t perform that action at this time.
0 commit comments