pytest-dev / pytest-dev/pytest

Stop testing a file on first fail

Open
#9,515 6 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: enhancement type: proposal
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?

This allows me to gather all failed files quicker, I don't need to know whether the remaining tests passed in this file.

Describe the solution you'd like

This will be equivalent to the -x option, but on a per-file basis. That is, pytest stops testing this file if it has one failed test.

This can save time when running on clouds like Github Action, if it fails fast, then I'll be charged less, knowing I have to re-run them.

Alternative Solutions

I'm not sure which plugin can solve this problem.

Additional context

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 by tracing pytest's existing -x option and the point where test execution advances between tests and files. Determine how a per-file stop condition would interact with existing failure handling, then add focused coverage showing that one failure stops the current file while other files can still run.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.