Skip to content

Commit

Permalink
Rewrite Item.location to be clearer with regard to types
Browse files Browse the repository at this point in the history
  • Loading branch information
bluetech authored and blueyed committed Jan 23, 2020
1 parent 0b6258a commit 9dcdea5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,10 @@ def reportinfo(self) -> Tuple[Union[py.path.local, str], Optional[int], str]:
@cached_property
def location(self) -> Tuple[str, Optional[int], str]:
location = self.reportinfo()
fspath = location[0]
if not isinstance(fspath, py.path.local):
fspath = py.path.local(fspath)
fspath = self.session._node_location_to_relpath(fspath)
if isinstance(location[0], py.path.local):
fspath = location[0]
else:
fspath = py.path.local(location[0])
relfspath = self.session._node_location_to_relpath(fspath)
assert type(location[2]) is str
return (fspath, location[1], location[2])
return (relfspath, location[1], location[2])

0 comments on commit 9dcdea5

Please sign in to comment.