pytest icon indicating copy to clipboard operation
pytest copied to clipboard

The teardown does not execute properly for session level fixture when we use --reruns

Open komalc9 opened this issue 1 year ago • 8 comments

When you will run the "test_example_fixture" test, You will observe that the teardown is never printed in console. This is restricting the clean up in my project.

NOTE: It happens only when we use rerun failed tests.

import pytest

@pytest.fixture(scope="session") def example_fixture(): print("\nSetup") yield print("Teardown")

@pytest.mark.flaky(reruns=1) def test_example_fixture(example_fixture): assert 0

komalc9 avatar May 03 '24 17:05 komalc9

I am using pytest 8.2 and pytest-rerunfailures 14.0

komalc9 avatar May 03 '24 17:05 komalc9

Please provide details on what command you run

RonnyPfannschmidt avatar May 04 '24 08:05 RonnyPfannschmidt

Running directly using pycharm.

Fyi it works in pytest 8.1.0

komalc9 avatar May 04 '24 14:05 komalc9

Also, I have tested this it works on pytest 8.1.0 but not in 8.2.0. With pytest-rerunfailures 14.0 or 12.0

komalc9 avatar May 06 '24 11:05 komalc9

This issue is stale because it has the status: needs information label and requested follow-up information was not provided for 14 days.

github-actions[bot] avatar May 21 '24 01:05 github-actions[bot]