-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
topic: collectionrelated to the collection phaserelated to the collection phase
Description
Observed behavior:
When I run pytest -s --lf --lfnf=none tests
and all the tests that failed during the previous run of the test suite where removed, all the tests are run.
Expected behavior:
I would expect that no tests are run at all in the above-mentioned situation, because the user explicitly requested to only run the tests that failed previously. Given that there are none, no tests should run.
Minimal reproduction:
Step 1: Run pytest tests
with the following tests/test_test.py
file:
def test_test1():
raise Exception()
def test_test2():
return
This produces the following output:
Test session starts (platform: linux, Python 3.12.11, pytest 8.4.1, pytest-sugar 1.0.0)
Using --randomly-seed=533107519
rootdir: /tmp/test
configfile: pyproject.toml
plugins: time-machine-2.16.0, env-1.1.5, cov-6.2.1, instafail-0.5.0, sugar-1.0.0, timeout-2.4.0, randomly-3.16.0, postgresql-7.0.2, asyncio-1.1.0, logfire-4.0.0
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 2 items
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― test_test1 ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
def test_test1():
> raise Exception()
E Exception
tests/test_test.py:2: Exception
tests/test_test.py ⨯✓ 100% ██████████
======================================================================= short test summary info =======================================================================
FAILED tests/test_test.py::test_test1 - Exception
Results (0.06s):
1 passed
1 failed
- tests/test_test.py:1 test_test1
Step 2: Run pytest --lf --lfnf=none tests
with the following tests/test_test.py
file (remove test1):
def test_test2():
return
This produces the following output:
Test session starts (platform: linux, Python 3.12.11, pytest 8.4.1, pytest-sugar 1.0.0)
Using --randomly-seed=304109397
rootdir: /tmp/test
configfile: pyproject.toml
plugins: time-machine-2.16.0, env-1.1.5, cov-6.2.1, instafail-0.5.0, sugar-1.0.0, timeout-2.4.0, randomly-3.16.0, postgresql-7.0.2, asyncio-1.1.0, logfire-4.0.0
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 1 item
run-last-failure: 1 known failures not in selected tests
tests/test_test.py ✓ 100% ██████████
Results (0.02s):
1 passed
Software versions:
- The above-mentioned issue happens on
pytest==8.4.1
Metadata
Metadata
Assignees
Labels
topic: collectionrelated to the collection phaserelated to the collection phase