Cache fixtures which raise pytest.skip.Exception and pytest.fail.Exception #467
Labels
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
Originally reported by: Floris Bruynooghe (BitBucket: flub, GitHub: flub)
Something I do quite a lot in fixtures is calling
pytest.skip(...)
orpytest.fail(...)
in session-scoped fixtures, usually for a service like a database server which is not available. However even though the fixture is scoped on the session py.test will not cache the exception raised from the fixture so the fixture will be executed again and again trying to connect to the same server over and over.Currently I solve this by caching the skip result manually on the fixture so that the fixture code can skip early, but I think it would be nice if py.test cached the exceptions raised from the fixture. While caching a generic exception might not be suitable I'm proposing to at least consider this for pytest.skip.Exception and pytest.fail.Exception.
The text was updated successfully, but these errors were encountered: