pytest-asyncio
pytest-asyncio copied to clipboard
Asyncio support for pytest
Hello! Something has been broken with the latest pytest-asyncio releases. Consider such code: ```python import asyncio import pytest @pytest.fixture(scope='session') def event_loop(): loop = asyncio.get_event_loop_policy().new_event_loop() yield loop loop.close() @pytest.fixture(scope='session') async def...
When running the test suite on Python 3.11, tests with a `@pytest.mark.asyncio` decorator, trigger a DeprecationWarning: ``` .../python3.11/site-packages/pytest_asyncio/plugin.py:884: DeprecationWarning: There is no current event loop _loop = asyncio.get_event_loop() ```
I was using a `event_loop` fixture to use a custom event loop class, and noticed the warning from pytest to not do that and use an event loop policy instead....
By default pytest does not import all modules so it is fine if they have import errors due to optional dependencies. You can cause pytest to import all modules if...
Contrary to the statements in the documentation ([here](https://github.com/pytest-dev/pytest-asyncio/blob/b60649a648912a79ce6f3443ca7ac2c67fe9a5b7/docs/source/how-to-guides/multiple_loops.rst?plain=1#L5) and [here](https://github.com/pytest-dev/pytest-asyncio/blob/b60649a648912a79ce6f3443ca7ac2c67fe9a5b7/docs/source/reference/fixtures/index.rst?plain=1#L34-L35)), the fixture is not only applied to all pytest-asyncio tests, but also applied to all other tests. ```python import asyncio...
When a user wants to run all tests in a session-scoped event loop, the documentation suggests implementing a _pytest_collection_modifyitems_ hook. In _auto_ mode the hook causes duplicate _asyncio_ markers to...
...and [according to pyright upstream](https://github.com/microsoft/pyright/issues/3497#issuecomment-1134850832), this is a bug in mypy, rather than in pyright. Type-checking pytest-asyncio itself yields a great many errors, starting with: ```none pytest-asyncio/pytest_asyncio/plugin.py:57:60 - error: Type...
#737 has added support for pytest 8. After some time, pytest-asyncio should drop support for the obsolete pytest 7.
I checked in all the files referenced below into this repo: https://github.com/danking/pytest-asyncio-confusion ``` pytest==7.4.3 pytest-asyncio==0.23.3 ``` Simple test file: ```python3 import pytest import asyncio @pytest.fixture(scope='session') async def foo(): yield asyncio.get_running_loop()...
test case for tangential issue discovered trying to [provide an example use case](https://github.com/pytest-dev/pytest-asyncio/issues/706#issuecomment-1918982285) for #706. When a function-scoped async fixture is used, `@pytest.mark.asyncio(scope="module")` on tests is ignored. Notably, when the...