From 794d4585d3b0e3c892ee97142e5c1d392928d372 Mon Sep 17 00:00:00 2001 From: Christian Boelsen Date: Thu, 28 Sep 2017 20:53:50 +0100 Subject: [PATCH] Remove unnecessary complexity in _check_initialpaths_for_relpath(). --- _pytest/main.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/_pytest/main.py b/_pytest/main.py index 6203f15c5..472cf77b1 100644 --- a/_pytest/main.py +++ b/_pytest/main.py @@ -522,11 +522,8 @@ class FSCollector(Collector): def _check_initialpaths_for_relpath(self): for initialpath in self.session._initialpaths: - parent_path = self.fspath - for _ in parent_path.parts(): - if parent_path.samefile(initialpath): - return self.fspath.relto(initialpath.dirname) - parent_path = parent_path.__class__(parent_path.dirname) + if self.fspath.common(initialpath) == initialpath: + return self.fspath.relto(initialpath.dirname) def _makeid(self): relpath = self.fspath.relto(self.config.rootdir)