Skip to content

Commit

Permalink
Put event_loop first among the fixtures of asyncio tests, fixes #154.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfagerholm authored and Tinche committed May 3, 2020
1 parent e5e3dc7 commit 238cced
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pytest_asyncio/plugin.py
Expand Up @@ -154,9 +154,11 @@ def inner(**kwargs):


def pytest_runtest_setup(item):
if 'asyncio' in item.keywords and 'event_loop' not in item.fixturenames:
if 'asyncio' in item.keywords:
# inject an event loop fixture for all async tests
item.fixturenames.append('event_loop')
if 'event_loop' in item.fixturenames:
item.fixturenames.remove('event_loop')
item.fixturenames.insert(0, 'event_loop')
if item.get_closest_marker("asyncio") is not None \
and not getattr(item.obj, 'hypothesis', False) \
and getattr(item.obj, 'is_hypothesis_test', False):
Expand Down

0 comments on commit 238cced

Please sign in to comment.