diff --git a/src/_pytest/nodes.py b/src/_pytest/nodes.py index 4a79bc86157..61c6bc90ab4 100644 --- a/src/_pytest/nodes.py +++ b/src/_pytest/nodes.py @@ -362,8 +362,7 @@ def _repr_failure_py( truncate_locals = True try: - os.getcwd() - abspath = False + abspath = os.getcwd() != str(self.config.invocation_dir) except OSError: abspath = True