Skip to content

Commit 794d458

Browse files
author
Christian Boelsen
committed
Remove unnecessary complexity in _check_initialpaths_for_relpath().
1 parent 14b6380 commit 794d458

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

_pytest/main.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -522,11 +522,8 @@ def __init__(self, fspath, parent=None, config=None, session=None):
522522

523523
def _check_initialpaths_for_relpath(self):
524524
for initialpath in self.session._initialpaths:
525-
parent_path = self.fspath
526-
for _ in parent_path.parts():
527-
if parent_path.samefile(initialpath):
528-
return self.fspath.relto(initialpath.dirname)
529-
parent_path = parent_path.__class__(parent_path.dirname)
525+
if self.fspath.common(initialpath) == initialpath:
526+
return self.fspath.relto(initialpath.dirname)
530527

531528
def _makeid(self):
532529
relpath = self.fspath.relto(self.config.rootdir)

0 commit comments

Comments
 (0)