pytest-dev / pytest-dev/pytest-xdist

last failed is not honored when collection error occurs

Open
#1,087 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.9k
Forks
287
Avg merge
9h 30m
Merged PRs (30d)
2

Description

Steps to reproduce

  1. create a folder names tests
  2. create a file test_foo.py with the content def test_1(): assert True
  3. create a file test_bar.py with the content
import pytest
@pytest.skip("reason")
def test_2():
    assert False
  1. Execute pytest tests/ -n2 -vv
  2. Execute pytest tests/ -n2 --lf -vv --last-failed-no-failures none

As you can see in the logs test_bar cannot be collected due to a collection error. However in the second run also test_foo is exeuted again which is not expected. When pytest is executed w/o pytest-xdist the execution fails directly bc of the collection error. If the collection error is removed (still assert False will lead to an error), the behavior is as expected.

I use the latest pytest, pytest-xdist version and python 3.12.1

Contributor guide

No contributing guide indexed for this repository

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 reproducing the issue with the two pytest commands and the provided test files. Trace how pytest-xdist handles collection errors together with --lf and --last-failed-no-failures; done means the second run does not execute test_foo when test_bar has a collection error, while behavior remains correct after removing that error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
distributed-systems, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.