pytest-dev / pytest-dev/pytest

Collection-error abort check lives in `pytest_runtestloop` instead of `pytest_collection`

Open
#15,028 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
14.5k
Forks
3.4k
Avg merge
2d 9h
Merged PRs (30d)
35

Description

What's the problem this feature will solve?

The collection-error abort check lives in the default pytest_runtestloop (src/_pytest/main.py), so the runtest phase inspects leftovers from collection instead of collection guarding itself.

Describe the solution you'd like

Move the testsfailed check into the default pytest_collection, keeping the exception and exit code. Both hooks are firstresult hooks, so audit which implementations bypass the check before moving it.

Alternative Solutions

Leave as is (behavior is correct).

Additional context

Deferred from #15012 (https://github.com/pytest-dev/pytest/pull/15012#discussion_r4005164212). This can be closed as wontfix if the compatibility impact outweighs the benefit.

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 in src/_pytest/main.py and compare the default pytest_collection and pytest_runtestloop implementations. Audit other implementations of these firstresult hooks to identify which bypass the collection-error check, while preserving the existing exception and exit code. Done means the check is owned by collection without compatibility regressions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.