| 682 | return path not in self._confcutdir.parents |
| 683 | |
| 684 | def _loadconftestmodules( |
| 685 | self, |
| 686 | path: pathlib.Path, |
| 687 | importmode: str | ImportMode, |
| 688 | rootpath: pathlib.Path, |
| 689 | *, |
| 690 | consider_namespace_packages: bool, |
| 691 | ) -> None: |
| 692 | if self._noconftest: |
| 693 | return |
| 694 | |
| 695 | directory = self._get_directory(path) |
| 696 | |
| 697 | # Optimization: avoid repeated searches in the same directory. |
| 698 | # Assumes always called with same importmode and rootpath. |
| 699 | if directory in self._dirpath2confmods: |
| 700 | return |
| 701 | |
| 702 | clist = [] |
| 703 | for parent in reversed((directory, *directory.parents)): |
| 704 | if self._is_in_confcutdir(parent): |
| 705 | conftestpath = parent / "conftest.py" |
| 706 | if conftestpath.is_file(): |
| 707 | mod = self._importconftest( |
| 708 | conftestpath, |
| 709 | importmode, |
| 710 | rootpath, |
| 711 | consider_namespace_packages=consider_namespace_packages, |
| 712 | ) |
| 713 | clist.append(mod) |
| 714 | self._dirpath2confmods[directory] = clist |
| 715 | |
| 716 | def _getconftestmodules(self, path: pathlib.Path) -> Sequence[types.ModuleType]: |
| 717 | directory = self._get_directory(path) |