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
def test__check_initialpaths_for_relpath() -> None: """Ensure that it handles dirs, and does not always use dirname.""" cwd = Path.cwd() class FakeSession1: _initialpaths = frozenset({cwd}) session = cast(pytest.Session, FakeSession1) assert nodes._check_initialpaths_for_relpath(session, cwd) == "" sub = cwd / "file" class FakeSession2: _initialpaths = frozenset({cwd}) session = cast(pytest.Session, FakeSession2) assert nodes._check_initialpaths_for_relpath(session, sub) == "file" outside = Path("/outside-this-does-not-exist") assert nodes._check_initialpaths_for_relpath(session, outside) is None