Skip to content

Commit

Permalink
Added check for non-function-scoped async fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Aug 1, 2020
1 parent 1d52e95 commit a8db694
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/anyio/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def wrapper(*args, **kwargs):

func = fixturedef.func
if (isasyncgenfunction(func) or iscoroutinefunction(func)) and 'anyio' in request.keywords:
if fixturedef.scope != 'function':
raise RuntimeError(f"Async fixtures are not supported at the {fixturedef.scope!r} "
f"scope - only the 'function' scope is supported")

strip_argnames = []
for argname in ('anyio_backend_name', 'anyio_backend_options'):
if argname not in fixturedef.argnames:
Expand Down

0 comments on commit a8db694

Please sign in to comment.