Skip to content

Commit bfd801d

Browse files
committed
Add comment as requested
1 parent cee62af commit bfd801d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/_pytest/nodes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ def _repr_failure_py(
360360
else:
361361
truncate_locals = True
362362

363+
# excinfo.getrepr() formats paths relative to the CWD if `abspath` is False.
364+
# It is possible for a fixture/test to change the CWD while this code runs, which
365+
# would then result in the user seeing confusing paths in the failure message.
366+
# To fix this, if the CWD changed, always display the full absolute path.
367+
# It will be better to just always display paths relative to invocation_dir, but
368+
# this requires a lot of plumbing (#6428).
363369
try:
364370
abspath = Path(os.getcwd()) != Path(self.config.invocation_dir)
365371
except OSError:

0 commit comments

Comments
 (0)