Skip to content

Cache fixtures which raise pytest.skip.Exception and pytest.fail.Exception #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pytestbot opened this issue Feb 21, 2014 · 1 comment
Closed
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature

Comments

@pytestbot
Copy link
Contributor

Originally reported by: Floris Bruynooghe (BitBucket: flub, GitHub: flub)


Something I do quite a lot in fixtures is calling pytest.skip(...) or pytest.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.


@pytestbot
Copy link
Contributor Author

Original comment by holger krekel (BitBucket: hpk42, GitHub: hpk42):


Add test for inter-dependent fixtures

Together with cc0a46a13ac4 this fixes issue 467.

@pytestbot pytestbot added the type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature label Jun 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: proposal proposal for a new feature, often to gather opinions or design the API around the new feature
Projects
None yet
Development

No branches or pull requests

1 participant