diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index f1b93a0a50f..5d3e3beb01f 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -534,10 +534,10 @@ def _set_initial_conftests( self._try_load_conftest(current, namespace.importmode, rootpath) def _is_in_confcutdir(self, path: Path) -> bool: - """Whether a path is within the confcutdir.""" + """Whether a path is within the confcutdir. When false, should not load conftest.""" if self._confcutdir is None: return True - return path not in self._confcutdir.parents + return self._confcutdir not in path.parents def _try_load_conftest( self, anchor: Path, importmode: Union[str, ImportMode], rootpath: Path