Skip to content

main,python: move __pycache__ ignore to pytest_ignore_collect #11814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/_pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -505,8 +508,6 @@ def collect(self) -> Iterable[Union[nodes.Item, nodes.Collector]]:
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):
Expand Down
2 changes: 0 additions & 2 deletions src/_pytest/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,8 +707,6 @@ def sort_key(entry: "os.DirEntry[str]") -> object:
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):
Expand Down