Skip to content

Move norecursedir check to the pytest_ignore_collect hook #11081

Description

@bluetech

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

Metadata

Metadata

Assignees

Labels

topic: collectionrelated to the collection phasetype: proposalproposal for a new feature, often to gather opinions or design the API around the new feature

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions