https://github.com/pytest-dev/pytest-asyncio
Asyncio support for pytest
https://github.com/pytest-dev/pytest-asyncio
asyncio pytest-plugin python testing
Last synced: 6 days ago
JSON representation
Asyncio support for pytest
- Host: GitHub
- URL: https://github.com/pytest-dev/pytest-asyncio
- Owner: pytest-dev
- License: apache-2.0
- Created: 2015-04-11T00:18:05.000Z (about 10 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T06:18:49.000Z (20 days ago)
- Last Synced: 2025-03-31T14:51:33.669Z (14 days ago)
- Topics: asyncio, pytest-plugin, python, testing
- Language: Python
- Homepage: https://pytest-asyncio.readthedocs.io
- Size: 898 KB
- Stars: 1,485
- Watchers: 35
- Forks: 160
- Open Issues: 49
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.rst
- Support: docs/support.rst
Awesome Lists containing this project
- awesome-asyncio - pytest-asyncio - Pytest support for asyncio. (Testing)
- awesome-asyncio-cn - pytest-asyncio - 支持 Asyncio 的 Pytest 库。 (测试)
- awesome-asyncio - pytest-asyncio - Pytest support for asyncio. (Testing)
- starred-awesome - pytest-asyncio - Pytest support for asyncio. (Python)
- awesome-python-backend - _pytest-asyncio_
- best-of-python-dev - GitHub - 16% open · ⏱️ 21.05.2024): (Testing Tools)
README
pytest-asyncio
==============.. image:: https://img.shields.io/pypi/v/pytest-asyncio.svg
:target: https://pypi.python.org/pypi/pytest-asyncio
.. image:: https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg
:target: https://github.com/pytest-dev/pytest-asyncio/actions?workflow=CI
.. image:: https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/main/graph/badge.svg
:target: https://codecov.io/gh/pytest-dev/pytest-asyncio
.. image:: https://img.shields.io/pypi/pyversions/pytest-asyncio.svg
:target: https://github.com/pytest-dev/pytest-asyncio
:alt: Supported Python versions
.. image:: https://img.shields.io/badge/Matrix-%23pytest--asyncio-brightgreen
:alt: Matrix chat room: #pytest-asyncio
:target: https://matrix.to/#/#pytest-asyncio:matrix.org`pytest-asyncio `_ is a `pytest `_ plugin. It facilitates testing of code that uses the `asyncio `_ library.
Specifically, pytest-asyncio provides support for coroutines as test functions. This allows users to *await* code inside their tests. For example, the following code is executed as a test item by pytest:
.. code-block:: python
@pytest.mark.asyncio
async def test_some_asyncio_code():
res = await library.do_something()
assert b"expected result" == resMore details can be found in the `documentation `_.
Note that test classes subclassing the standard `unittest `__ library are not supported. Users
are advised to use `unittest.IsolatedAsyncioTestCase `__
or an async framework such as `asynctest `__.pytest-asyncio is available under the `Apache License 2.0 `_.
Installation
------------To install pytest-asyncio, simply:
.. code-block:: bash
$ pip install pytest-asyncio
This is enough for pytest to pick up pytest-asyncio.
Contributing
------------
Contributions are very welcome. Tests can be run with ``tox``, please ensure
the coverage at least stays the same before you submit a pull request.