Skip to content

Commit

Permalink
Add comment as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoddemus committed May 30, 2020
1 parent cee62af commit bfd801d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/_pytest/nodes.py
Expand Up @@ -360,6 +360,12 @@ def _repr_failure_py(
else:
truncate_locals = True

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

0 comments on commit bfd801d

Please sign in to comment.