From 1f2a70d586d24778c56588a0738e38fc21839ea9 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Wed, 16 Mar 2022 17:52:04 +0530 Subject: [PATCH] Check Path in confcudir parent hierarchy Fixes: #9767 Signed-off-by: Abhijeet Kasurde --- src/_pytest/config/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/_pytest/config/__init__.py b/src/_pytest/config/__init__.py index f4818c861cf..91ad3f094ff 100644 --- a/src/_pytest/config/__init__.py +++ b/src/_pytest/config/__init__.py @@ -538,11 +538,7 @@ def _is_in_confcutdir(self, path: Path) -> bool: """ if self._confcutdir is None: return True - try: - path.relative_to(self._confcutdir) - except ValueError: - return False - return True + return path not in self._confcutdir.parents def _try_load_conftest( self, anchor: Path, importmode: Union[str, ImportMode], rootpath: Path