pytest-dev / pytest-rerunfailures

a pytest plugin that re-runs failed tests up to -n times to eliminate flakey failures
Other
369 stars 82 forks source link

The teardown does not execute properly for session level fixture when we use `--reruns` (from `pytest-rerunfailures`) #272

Open komalc9 opened 2 months ago

komalc9 commented 2 months ago

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 commented 2 months ago

I am using pytest 8.2 and pytest-rerunfailures 14.0

RonnyPfannschmidt commented 2 months ago

Please provide details on what command you run

komalc9 commented 2 months ago

Running directly using pycharm.

Fyi it works in pytest 8.1.0

komalc9 commented 2 months ago

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

github-actions[bot] commented 1 month ago

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

komalc9 commented 1 month ago

i used below command: pytest name_of_test

komalc9 commented 1 month ago

What else is required?

The-Compiler commented 1 month ago

This sounds like an issue in pytest-rerunfailures rather than pytest. But given that it started appearing with pytest 8.2.0, it might still be interesting to see what change in pytest caused it.