pytest-dev / pytest-dev/pytest
Last-failed option missing tests when failed tests include a mix stable and random node IDs
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
- a detailed description of the bug or problem you are having
- output of
pip listfrom the virtual environment you are usingattrs (22.1.0) Faker (14.2.0) importlib-metadata (4.12.0) iniconfig (1.1.1) packaging (21.3) pip (9.0.1) pkg-resources (0.0.0) pluggy (1.0.0) py (1.11.0) pyparsing (3.0.9) pytest (7.1.2) pytest-faker (2.0.0) python-dateutil (2.8.2) setuptools (39.0.1) six (1.16.0) tomli (2.0.1) typing-extensions (4.3.0) zipp (3.8.1) - pytest and operating system versions
- Python 3.7.5
- pytest 7.1.2
- Ubuntu 18.04.6
- minimal example if possible
- Start with the given test code.
import pytest from faker import Faker fake = Faker() @pytest.mark.parametrize('a', (fake.pystr(),)) def test_asd(a): assert False def test_zxc(): assert False - Run pytest once
pytest --tb=no -q FF [100%] ====================================== short test summary info ======================================= FAILED test_asd.py::test_asd[fPLeEKOcteuKAoJyUmpz] - assert False FAILED test_asd.py::test_zxc - assert False 2 failed in 0.05s - Run pytest again with the
--last-failedoptionpytest --tb=no -q --lf F [100%] ====================================== short test summary info ======================================= FAILED test_asd.py::test_zxc - assert False 1 failed in 0.05s - Expect both tests to be rerun - only
test_zxcis rerun
Initially we thought this was because test_asd is using a randomized parameterized fixture. Since the node IDs are essentially random it would make sense pytest doesn't reselect them.
But if you remove test_zxc in the example above and run steps 2 and 3, pytest actually works and reruns test_asd and the node IDs are different each time.
pytest --tb=no -q; pytest --tb=no -q --lf
F [100%]
====================================== short test summary info =======================================
FAILED test_asd.py::test_asd[IBWBNcpQQilmccBLPmIB] - assert False
1 failed in 0.05s
F [100%]
====================================== short test summary info =======================================
FAILED test_asd.py::test_asd[AsUfmfLBeTdfakmHXPmm] - assert False
1 failed in 0.05s
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with pytest's --last-failed implementation and reproduce the report using the parametrized test and ordinary failing test shown in the issue. Trace how failed node IDs are stored and selected when stable and randomized IDs are mixed. Done means a subsequent --last-failed run reruns both failures, with regression coverage for this mixed case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100