pytest-dev / pytest-dev/pytest

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

Open
#12,312 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

topic: collection topic: reporting type: performance
Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with pytest's collection code and reporting code, using the --ignore flag and norecursedirs configuration as the intended suggestions. Trace how directory traversal records elapsed time and collected test files, then determine how the depth-first warning behavior fits into collection. Done means slow directories with no collected tests produce a useful warning without recursing further when the stated conditions apply.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.