pytest-rerunfailures icon indicating copy to clipboard operation
pytest-rerunfailures copied to clipboard

Provide example of @pytest.fixure that is flaky

Open trajano opened this issue 9 months ago • 6 comments

I tried to do this

@pytest.fixture
@pytest.mark.flaky
def the_server(

But it didn't seem to work as I expected. Is that the right way of doing it as I don't see it in the readme

Perhaps something on this page https://pytest-rerunfailures.readthedocs.io/latest/mark.html

trajano avatar Mar 28 '25 22:03 trajano

I don't think marks work on fixtures.

webknjaz avatar Mar 28 '25 22:03 webknjaz

Then the statement in the README should say that as a rule then right now it says

This plugin may not be used with class, module, and package level fixtures.

So I presume function fixtures should be fine.

trajano avatar Mar 28 '25 22:03 trajano

I don't think that this makes any sense because every single project using pytest would have to document this. Applying markers is a feature of pytest. There's no reason for each plugin to explain how pytest works.

webknjaz avatar Mar 28 '25 22:03 webknjaz

https://stackoverflow.com/a/58493116/595220

webknjaz avatar Mar 28 '25 22:03 webknjaz

I mean if the rerunfailures is not supposed to work on fixtures it should just say

This plugin may not be used with fixtures.

Rather than qualifying it with class, module, and package. Assuming that it isn't supported.

trajano avatar Mar 28 '25 22:03 trajano

You can apply marks where pytest lets you 🤷‍♂️

webknjaz avatar Mar 28 '25 22:03 webknjaz

That sentence is referring to using the plugin with (tests that use) fixtures, not on fixtures. It's outdated however, see #291.

The-Compiler avatar Mar 29 '25 22:03 The-Compiler