-
Notifications
You must be signed in to change notification settings - Fork 40
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
Make @fixture
and @parametrize
async aware
#301
Conversation
@fixture
and @parametrize` async aware@fixture
and @parametrize
async aware
5183753
to
18f3ee7
Compare
Added test that check that the decorated function ist still an async generator, coroutine or generator.
|
@smarie Is there any chance this can be reviewed 🙏🏻 ? |
@smarie I would really appreciate that this gets merged soon, because this is the only blocker left for my codebase to switch from trio to anyio. |
Congrats for this nice piece of work @jgersti ! I am impressed by the overall quality and consistency, on a difficult topic, with multi-version support. Thanks ! Let's ship this now |
Make
_decorate_fixture_plus
and_parametrize_plus
async aware by forwarding the function characteristics (coroutine (Python 3.5+) / asyncgen (Python 3.6+)) properly. Also useyield from
for Python 3.3+.I did not touch
@parametrize_with_cases
, since i am unsure if it even makes sense to have async cases (these would have to be transformed into fixtures).There is no guarantee that this fix will work before Python 3.8 because of pytest internals (see below). Some async framework plugins workaround around that by providing a way to force a fixture to be async (mostly by offering their own
fixture
decorator) which is incompatible with this plugin)There is one big caveat: there are no test yet and i am unsure how to test.Because testing against just one async framework is not very helpful and practially all pytest plugins for the different async frameworks are mutually exclusive. Ideally I would want to check that the property of being a coroutines or async generators passes through the above mentioned functions/decorators. But since pytest internally uses
functools.wraps
, which in turn usesfunctools.partial
, andinspect.iscoroutinefunction
/inspect.isasyncgenfunction
only work forfunctools.partial
for python 3.8+, testing for older python versions might be difficult/impossible.fixes #286