Merge pull request #11814 from bluetech/pycache-ignore-collect

main,python: move `__pycache__` ignore to `pytest_ignore_collect`
This commit is contained in:
Ronny Pfannschmidt 2024-01-14 17:26:34 +01:00 committed by GitHub
commit 3acbdc2f79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -376,6 +376,9 @@ def _in_venv(path: Path) -> bool:
def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[bool]:
if collection_path.name == "__pycache__":
return True
ignore_paths = config._getconftest_pathlist(
"collect_ignore", path=collection_path.parent
)
@ -505,8 +508,6 @@ class Dir(nodes.Directory):
ihook = self.ihook
for direntry in scandir(self.path):
if direntry.is_dir():
if direntry.name == "__pycache__":
continue
path = Path(direntry.path)
if not self.session.isinitpath(path, with_parents=True):
if ihook.pytest_ignore_collect(collection_path=path, config=config):

View File

@ -707,8 +707,6 @@ class Package(nodes.Directory):
ihook = self.ihook
for direntry in scandir(self.path, sort_key):
if direntry.is_dir():
if direntry.name == "__pycache__":
continue
path = Path(direntry.path)
if not self.session.isinitpath(path, with_parents=True):
if ihook.pytest_ignore_collect(collection_path=path, config=config):