Skip to content

Commit

Permalink
remove _check_initialpaths_for_relpath
Browse files Browse the repository at this point in the history
  • Loading branch information
blueyed committed Feb 10, 2020
1 parent 89bf5ba commit 4d1836a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 37 deletions.
17 changes: 2 additions & 15 deletions src/_pytest/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,6 @@ def _prunetraceback(self, excinfo):
excinfo.traceback = ntraceback.filter()


def _check_initialpaths_for_relpath(session, fspath):
for initial_path in session._initialpaths:
if fspath.common(initial_path) == initial_path:
return fspath.relto(initial_path)


class FSHookProxy:
def __init__(
self, fspath: py.path.local, pm: PytestPluginManager, remove_mods
Expand Down Expand Up @@ -427,15 +421,8 @@ def __init__(

if nodeid is None:
nodeid = session._node_location_to_relpath(self.fspath)

if not nodeid:
if not nodeid:
assert 0, (2, self.fspath, parent, config, session)
nodeid = _check_initialpaths_for_relpath(session, fspath)
if not nodeid:
assert 0, (self.fspath, parent, config, session)
nodeid = str(self.fspath)
if nodeid and os.sep != SEP:
assert nodeid, (2, fspath, session.config.rootdir)
if os.sep != SEP:
nodeid = nodeid.replace(os.sep, SEP)

super().__init__(name, parent, config, session, nodeid=nodeid, fspath=fspath)
Expand Down
22 changes: 0 additions & 22 deletions testing/test_nodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import py

import pytest
from _pytest import nodes

Expand Down Expand Up @@ -31,23 +29,3 @@ def test():
)
with pytest.raises(ValueError, match=".*instance of PytestWarning.*"):
items[0].warn(UserWarning("some warning"))


def test__check_initialpaths_for_relpath():
"""Ensure that it handles dirs, and does not always use dirname."""
cwd = py.path.local()

class FakeSession:
_initialpaths = [cwd]

assert nodes._check_initialpaths_for_relpath(FakeSession, cwd) == ""

sub = cwd.join("file")

class FakeSession:
_initialpaths = [cwd]

assert nodes._check_initialpaths_for_relpath(FakeSession, sub) == "file"

outside = py.path.local("/outside")
assert nodes._check_initialpaths_for_relpath(FakeSession, outside) is None

0 comments on commit 4d1836a

Please sign in to comment.