pytest icon indicating copy to clipboard operation
pytest copied to clipboard

Warn if collection spends >5s traversing a directory without collecting any tests

Open Zac-HD opened this issue 1 year ago • 1 comments

I recently saw https://github.com/pytest-dev/pytest/issues/5851#issuecomment-2094075457, which made me wonder if we could automatically detect similar cases and suggest using the --ignore flag or norecursedirs config option.

Tracking the time spent in collection on a per-directory basis and whether any test files were collected should be pretty straightforward, and from there it's just the reporting code. Specifically: depth-first search over the tree, don't recurse into children if the current node triggered the warning or took <= 5s. Alternatively, maybe this could be integrated with the collection code so that we don't need a separate step.

Zac-HD avatar May 12 '24 20:05 Zac-HD

Kinda related, but maybe when the --durations option is used, we also display the collection time per directory ?

Pierre-Sassoulas avatar May 13 '24 04:05 Pierre-Sassoulas