-
Notifications
You must be signed in to change notification settings - Fork 3
Add support for generators as pytest fixture classes #9
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
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| Note: Async fixtures require `pytest-asyncio` or another async pytest plugin to be installed. | ||
|
|
||
| ### Lifespan Support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever we write docs for features, it's much better to write them in terms of features, not implementation details — this turns them into true problem solving guides instead of technical documentation.
In this case, the section and notes within it should probably refer to "setup and tear down" instead of lifespan
|
|
||
| from pytest_fixture_classes import fixture_class | ||
|
|
||
| execution_log: list[str] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it maybe make sense to keep the execution log per test? The whole clearing thing feels like an anti-pattern here, removing the ability to parallelize tests. It isn't a big problem for this library but I do feel like a testing library should be promoting the right patterns.
| has_lifespan = hasattr(fixture_cls, "lifespan") | ||
| is_async_lifespan = False | ||
|
|
||
| if has_lifespan: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just inserting a lifespan that does nothing in case there is no lifespan? It should make the code much simpler and less duplicated
No description provided.