diff --git a/README.rst b/README.rst index 9695de4d..eade16d1 100644 --- a/README.rst +++ b/README.rst @@ -81,7 +81,7 @@ event loop. This will take effect even if you're using the .. code-block:: python - @pytest.yield_fixture() + @pytest.fixture def event_loop(): loop = MyCustomLoop() yield loop diff --git a/pytest_asyncio/plugin.py b/pytest_asyncio/plugin.py index 39b9c698..64ec03de 100644 --- a/pytest_asyncio/plugin.py +++ b/pytest_asyncio/plugin.py @@ -166,7 +166,7 @@ def pytest_runtest_setup(item): ) -@pytest.yield_fixture +@pytest.fixture def event_loop(request): """Create an instance of the default event loop for each test case.""" loop = asyncio.get_event_loop_policy().new_event_loop() diff --git a/tests/conftest.py b/tests/conftest.py index a2debdf3..6203cf82 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ collect_ignore.append("async_fixtures/test_nested_36.py") -@pytest.yield_fixture() +@pytest.fixture def dependent_fixture(event_loop): """A fixture dependent on the event_loop fixture, doing some cleanup.""" counter = 0 diff --git a/tests/multiloop/conftest.py b/tests/multiloop/conftest.py index 50d70a94..1b62a1d0 100644 --- a/tests/multiloop/conftest.py +++ b/tests/multiloop/conftest.py @@ -8,7 +8,7 @@ class CustomSelectorLoop(asyncio.SelectorEventLoop): pass -@pytest.yield_fixture() +@pytest.fixture def event_loop(): """Create an instance of the default event loop for each test case.""" loop = CustomSelectorLoop()