Node.location: handle str with _node_location_to_relpath

This commit is contained in:
Daniel Hahler 2020-01-21 12:26:29 +01:00
parent ef112fd7dd
commit 1350c601dc
2 changed files with 8 additions and 3 deletions

View File

@ -462,7 +462,9 @@ class Item(Node):
@cached_property
def location(self) -> Tuple[str, Optional[int], str]:
location = self.reportinfo()
assert isinstance(location[0], py.path.local), location[0]
fspath = self.session._node_location_to_relpath(location[0])
fspath = location[0]
if not isinstance(fspath, py.path.local):
fspath = py.path.local(fspath)
fspath = self.session._node_location_to_relpath(fspath)
assert type(location[2]) is str
return (fspath, location[1], location[2])

View File

@ -395,9 +395,12 @@ def test_raises(testdir):
raise BaseException
"""
)
result = testdir.runpytest()
result = testdir.runpytest("-vv")
result.stdout.fnmatch_lines(
[
"test_raises.py::test_raises_runtimeerror PASSED*",
"test_raises.py::test_raises_baseexception_not_caught FAILED*",
"test_raises.py::test_raises_baseexception_caught PASSED*",
"*= FAILURES =*",
"*_ test_raises_baseexception_not_caught _*",
"",