Skip to content

Commit 9dcdea5

Browse files
bluetechblueyed
authored andcommitted
Rewrite Item.location to be clearer with regard to types
1 parent 0b6258a commit 9dcdea5

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/_pytest/nodes.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,10 @@ def reportinfo(self) -> Tuple[Union[py.path.local, str], Optional[int], str]:
462462
@cached_property
463463
def location(self) -> Tuple[str, Optional[int], str]:
464464
location = self.reportinfo()
465-
fspath = location[0]
466-
if not isinstance(fspath, py.path.local):
467-
fspath = py.path.local(fspath)
468-
fspath = self.session._node_location_to_relpath(fspath)
465+
if isinstance(location[0], py.path.local):
466+
fspath = location[0]
467+
else:
468+
fspath = py.path.local(location[0])
469+
relfspath = self.session._node_location_to_relpath(fspath)
469470
assert type(location[2]) is str
470-
return (fspath, location[1], location[2])
471+
return (relfspath, location[1], location[2])

0 commit comments

Comments
 (0)