-
-
Notifications
You must be signed in to change notification settings - Fork 25
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
Figure out how to stop fighting with pytest-asyncio over fixtures #10
Comments
(accidentally posted this too soon; if you got an empty notification then click through to the issue to see my actual text.) |
Oh heh, looking further into python-trio/trio#27 (comment) I see that you already proposed something similar. I guess my innovation above is that if people are using a Small tweak we could do: make our special decorator accept non-async functions and silently treat them like regular |
Coming back around to this again, I'd like to make a more refined proposal:
I think this provides a good balance of functionality for both values of the "everything is trio" config flag, should provide useful error messages when misused, and has at least the potential to play nicely with packages like Of course, right now, any system that allows for plain |
- Add @pytest_trio.trio_fixture for explicitly marking a fixture as being a trio fixture - Make the nursery fixture a @trio_fixture - Refactor Trio fixture classes into one class - Check for trio marker instead of trio keyword (fixes python-triogh-43) - This also raises the minimum pytest version to 3.6 - Raise an error if a Trio fixture is used with a non-function scope (fixes python-triogh-18) - Raise an error if a Trio fixture is used with a non-Trio test I think this also closes python-triogh-10's discussion, though we still need to convince pytest-asyncio to fix their side of things.
- Add @pytest_trio.trio_fixture for explicitly marking a fixture as being a trio fixture - Make the nursery fixture a @trio_fixture - Refactor Trio fixture classes into one class - Check for trio marker instead of trio keyword (fixes python-triogh-43) - This also raises the minimum pytest version to 3.6 - Raise an error if a Trio fixture is used with a non-function scope (fixes python-triogh-18) - Raise an error if a Trio fixture is used with a non-Trio test I think this also closes python-triogh-10's discussion, though we still need to convince pytest-asyncio to fix their side of things.
- Add @pytest_trio.trio_fixture for explicitly marking a fixture as being a trio fixture - Make the nursery fixture a @trio_fixture - Refactor Trio fixture classes into one class - Check for trio marker instead of trio keyword (fixes python-triogh-43) - This also raises the minimum pytest version to 3.6 - Raise an error if a Trio fixture is used with a non-function scope (fixes python-triogh-18) - Raise an error if a Trio fixture is used with a non-Trio test I think this also closes python-triogh-10's discussion, though we still need to convince pytest-asyncio to fix their side of things.
As noted in python-trio/trio#27 (comment):
Here's my suggestion: since fixtures already have to be explicitly decorated, it's not too onerous to ask the user to also explicitly say which kind of async fixture they want. So instead of writing
you'd write
We should probably also continue to install a fixture hook, but make it just detect when someone has accidentally written
@fixture async def ...
so we can give an error message saying to use@trio_fixture
instead.We should also try to convince the pytest-asyncio folks to switch to this system (CC @Tinche). Especially if we are going to install a fixture hook that will randomly cause their thing to break and tell their users to use
@trio_fixture
instead :-)The text was updated successfully, but these errors were encountered: