main,python: move `__pycache__` ignore to `pytest_ignore_collect`
This removes one thing that directory collectors need to worry about. This adds one hook dispatch per `__pycache__` file, but I think it's worth it for consistency.
This commit is contained in:
parent
2bb0eca347
commit
2413d1b214
|
@ -376,6 +376,9 @@ def _in_venv(path: Path) -> bool:
|
||||||
|
|
||||||
|
|
||||||
def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[bool]:
|
def pytest_ignore_collect(collection_path: Path, config: Config) -> Optional[bool]:
|
||||||
|
if collection_path.name == "__pycache__":
|
||||||
|
return True
|
||||||
|
|
||||||
ignore_paths = config._getconftest_pathlist(
|
ignore_paths = config._getconftest_pathlist(
|
||||||
"collect_ignore", path=collection_path.parent
|
"collect_ignore", path=collection_path.parent
|
||||||
)
|
)
|
||||||
|
@ -505,8 +508,6 @@ class Dir(nodes.Directory):
|
||||||
ihook = self.ihook
|
ihook = self.ihook
|
||||||
for direntry in scandir(self.path):
|
for direntry in scandir(self.path):
|
||||||
if direntry.is_dir():
|
if direntry.is_dir():
|
||||||
if direntry.name == "__pycache__":
|
|
||||||
continue
|
|
||||||
path = Path(direntry.path)
|
path = Path(direntry.path)
|
||||||
if not self.session.isinitpath(path, with_parents=True):
|
if not self.session.isinitpath(path, with_parents=True):
|
||||||
if ihook.pytest_ignore_collect(collection_path=path, config=config):
|
if ihook.pytest_ignore_collect(collection_path=path, config=config):
|
||||||
|
|
|
@ -707,8 +707,6 @@ class Package(nodes.Directory):
|
||||||
ihook = self.ihook
|
ihook = self.ihook
|
||||||
for direntry in scandir(self.path, sort_key):
|
for direntry in scandir(self.path, sort_key):
|
||||||
if direntry.is_dir():
|
if direntry.is_dir():
|
||||||
if direntry.name == "__pycache__":
|
|
||||||
continue
|
|
||||||
path = Path(direntry.path)
|
path = Path(direntry.path)
|
||||||
if not self.session.isinitpath(path, with_parents=True):
|
if not self.session.isinitpath(path, with_parents=True):
|
||||||
if ihook.pytest_ignore_collect(collection_path=path, config=config):
|
if ihook.pytest_ignore_collect(collection_path=path, config=config):
|
||||||
|
|
Loading…
Reference in New Issue