Skip to content
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

Move norecursedir check to the pytest_ignore_collect hook #11081

Closed
bluetech opened this issue Jun 5, 2023 · 0 comments · Fixed by #11082
Closed

Move norecursedir check to the pytest_ignore_collect hook #11081

bluetech opened this issue Jun 5, 2023 · 0 comments · Fixed by #11082
Assignees
Labels
topic: collection related to the collection phase type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@bluetech
Copy link
Member

bluetech commented Jun 5, 2023

Currently the two recursive collectors Session and Package perform the norecursedir check directly in the collector:

pytest/src/_pytest/main.py

Lines 566 to 568 in 85c5bd2

norecursepatterns = self.config.getini("norecursedirs")
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
return False

norecursepatterns = self.config.getini("norecursedirs")
if any(fnmatch_ex(pat, fspath) for pat in norecursepatterns):
return False

I think it would be strictly better to move this check to main's pytest_ignore_collect hookimpl:

  • Less duplication
  • Better decoupling -- only main knows about the option it defines
  • More control for plugins
@bluetech bluetech added type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature topic: collection related to the collection phase labels Jun 5, 2023
@bluetech bluetech self-assigned this Jun 5, 2023
bluetech added a commit to bluetech/pytest that referenced this issue Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: collection related to the collection phase type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant