Skip to content

Commit 4d1836a

Browse files
committed
remove _check_initialpaths_for_relpath
1 parent 89bf5ba commit 4d1836a

File tree

2 files changed

+2
-37
lines changed

2 files changed

+2
-37
lines changed

src/_pytest/nodes.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,6 @@ def _prunetraceback(self, excinfo):
391391
excinfo.traceback = ntraceback.filter()
392392

393393

394-
def _check_initialpaths_for_relpath(session, fspath):
395-
for initial_path in session._initialpaths:
396-
if fspath.common(initial_path) == initial_path:
397-
return fspath.relto(initial_path)
398-
399-
400394
class FSHookProxy:
401395
def __init__(
402396
self, fspath: py.path.local, pm: PytestPluginManager, remove_mods
@@ -427,15 +421,8 @@ def __init__(
427421

428422
if nodeid is None:
429423
nodeid = session._node_location_to_relpath(self.fspath)
430-
431-
if not nodeid:
432-
if not nodeid:
433-
assert 0, (2, self.fspath, parent, config, session)
434-
nodeid = _check_initialpaths_for_relpath(session, fspath)
435-
if not nodeid:
436-
assert 0, (self.fspath, parent, config, session)
437-
nodeid = str(self.fspath)
438-
if nodeid and os.sep != SEP:
424+
assert nodeid, (2, fspath, session.config.rootdir)
425+
if os.sep != SEP:
439426
nodeid = nodeid.replace(os.sep, SEP)
440427

441428
super().__init__(name, parent, config, session, nodeid=nodeid, fspath=fspath)

testing/test_nodes.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import py
2-
31
import pytest
42
from _pytest import nodes
53

@@ -31,23 +29,3 @@ def test():
3129
)
3230
with pytest.raises(ValueError, match=".*instance of PytestWarning.*"):
3331
items[0].warn(UserWarning("some warning"))
34-
35-
36-
def test__check_initialpaths_for_relpath():
37-
"""Ensure that it handles dirs, and does not always use dirname."""
38-
cwd = py.path.local()
39-
40-
class FakeSession:
41-
_initialpaths = [cwd]
42-
43-
assert nodes._check_initialpaths_for_relpath(FakeSession, cwd) == ""
44-
45-
sub = cwd.join("file")
46-
47-
class FakeSession:
48-
_initialpaths = [cwd]
49-
50-
assert nodes._check_initialpaths_for_relpath(FakeSession, sub) == "file"
51-
52-
outside = py.path.local("/outside")
53-
assert nodes._check_initialpaths_for_relpath(FakeSession, outside) is None

0 commit comments

Comments
 (0)