Control: forwarded 1073443 https://github.com/pytest-dev/pytest/issues/12284 Control: tags 1073443 + upstream
It looks like rerunfailures plugin erroneously deletes the session teardown from the execution stack if a test fails and is rerun. You can reproduce the bug with the attached script pytest_session_fixture.py:
- Running `pytest pytest_session_fixture.py -s` will show "session teardown" is run regardless of the flaky test outcome - Running `pytest pytest_session_fixture.py -s --reruns 1` will only show "session teardown" if the flaky test succeeds on the first try.
This bug was exposed by a change in pytest 8.2 and currently prevents pytest from migrating to testing.
Cheers Timo -- ⢀⣴⠾⠻⢶⣦⠀ ╭────────────────────────────────────────────────────╮ ⣾⠁⢠⠒⠀⣿⡁ │ Timo Röhling │ ⢿⡄⠘⠷⠚⠋⠀ │ 9B03 EBB9 8300 DF97 C2B1 23BF CC8C 6BDD 1403 F4CA │ ⠈⠳⣄⠀⠀⠀⠀ ╰────────────────────────────────────────────────────╯
#!/usr/bin/python3 import pytest import random @pytest.fixture(scope="session", autouse=True) def my_session(): print("session setup") yield print("session teardown") @pytest.fixture(autouse=True) def my_function(): print("function setup") yield print("function teardown") def test_flaky(): print("test_flaky") assert random.randint(0, 1) == 0
signature.asc
Description: PGP signature