Michael Seifert

Results 244 comments of Michael Seifert

The [migration guide](https://pytest-asyncio.readthedocs.io/en/v0.24.0/how-to-guides/migrate_from_0_21.html) suggests converting such tests to async tests and use _get_running_loop_ inside the async test. Following your example: ```python @pytest_asyncio.fixture() async def some_fixture(): # do some sync stuff...

@tuukkamustonen would it be possible for you to replace > def test_something(event_loop): > event_loop.run_until_complete(...) with ```python async def test_something(): event_loop = asyncio.get_running_loop( ) event_loop.run_until_complete(...) ``` or ```python async def test_something():...

> No, that converts the whole test as `async`, we want to keep them as _sync_. > > The tests might be doing a lot of things, ie. calling DB,...

> Hey, just for clarity's sake, I'm not arguing `pytest-asyncio` should do something differently 😃 Merely expressing the use case, and that the change might bring some users some troubles....

Thanks for the investigation! I suspected that pytest-asyncio will have to check its performance someday. There's currently no setup to do any performance testing, though. I promise to look into...

@etripier Even though this has been partially addressed in v0.25.1, should see further improvements test collection performance with pytest-asyncio v1.0.0

The `event_loop` fixture has been deprecated in v0.23 and removed in v1.0.0. Therefore, I will close this issue as obsolete.

@twisteroidambassador Thanks for the clarification! > To properly fix this in pytest-asyncio, it's probably necessary to ensure the lifecycle of the event loop fully encompass everything inside the test function...

Thanks for the code example. In your specific code, the issue is that the test and the fixture run in different asyncio event loops. Each pytest scope has its own...

When I add the following code snippet to `conftest.py` (instead of `@pytest.mark.asyncio(scope="session"` as mentioned in my previous comment), your provided example runs as expected. ```python import pytest from pytest_asyncio import...