# pytest-asyncio

> Pytest support for asyncio

- **URL**: https://www.freshcrate.ai/projects/pytest-asyncio
- **Author**: pypi
- **Category**: Frameworks
- **Latest version**: `v1.4.0` (2026-05-26)
- **License**: Unknown
- **Source**: https://github.com/pytest-dev/pytest-asyncio/issues
- **Homepage**: https://pypi.org/project/pytest-asyncio/
- **Language**: Python
- **GitHub**: 1,635 stars, 179 forks
- **Registry**: pypi (`pytest-asyncio`)
- **Tags**: `pypi`

## Description

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 <https://pytest-asyncio.readthedocs.io/en/latest/>`_ is a `pytest <https://docs.pytest.org/en/latest/contents.html>`_ plugin. It facilitates testing of code that uses the `asyncio <https://docs.python.org/3/library/asyncio.html>`_ 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" == res

More details can be found in the `documentation <https://pytest-asyncio.readthedocs.io/en/latest/>`_.

Note that test classes subclassing the standard `unittest <https://docs.python.org/3/library/unittest.html>`__ library are not supported. Users
are advised to use `unittest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`__
or an async framework such as `asynctest <https://asynctest.readthedocs.io/en/latest>`__.


pytest-asyncio is available under the `Apache License 2.0 <https://github.com/pytest-dev/pytest-asyncio/blob/main/LICENSE>`_.


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.

## Recent releases

| Version | Date | Urgency | Changes |
| --- | --- | --- | --- |
| `v1.4.0` | 2026-05-26 | High | # [1.4.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.4.0) - 2026-05-26  ## Deprecated  -   Overriding the *event_loop_policy* fixture is deprecated. Use the `pytest_asyncio_loop_factories` hook instead. ([#1419](https://github.com/pytest-dev/pytest-asyncio/issues/1419))  ## Added  -   Added the `pytest_asyncio_loop_factories` hook to parametrize asyncio tests with custom event loop factories.      The hook returns a mapping of factory names to loop factories, and `pytest.mark. |
| `1.3.0` | 2026-04-21 | Low | Imported from PyPI (1.3.0) |
| `v1.4.0a1` | 2026-04-15 | High | # [1.4.0a1](https://github.com/pytest-dev/pytest-asyncio/tree/1.4.0a1) - 2026-04-15  ## Added  -   Added the `pytest_asyncio_loop_factories` hook to parametrize asyncio tests with custom event loop factories.      The hook returns a mapping of factory names to loop factories, and `pytest.mark.asyncio(loop_factories=[...])` selects a subset of configured factories per test. When a single factory is configured, test names are unchanged on pytest 8.4+.      Synchronous `@pytest_asyncio.fixt |
| `v1.4.0a0` | 2026-04-15 | High | # [1.4.0a0](https://github.com/pytest-dev/pytest-asyncio/tree/1.4.0a0) - 2026-03-25  ## Added  -   Added the `pytest_asyncio_loop_factories` hook to parametrize asyncio tests with custom event loop factories.      The hook now returns a mapping of factory names to loop factories, and `pytest.mark.asyncio(loop_factories=[...])` can be used to select a subset of configured factories per test. ([#1164](https://github.com/pytest-dev/pytest-asyncio/issues/1164))  ## Changed  -   Improved th |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |
| `v1.3.0` | 2025-11-10 | Low | # [1.3.0](https://github.com/pytest-dev/pytest-asyncio/tree/1.3.0) - 2025-11-10  ## Removed  -   Support for Python 3.9 ([#1278](https://github.com/pytest-dev/pytest-asyncio/issues/1278))  ## Added  -   Support for pytest 9 ([#1279](https://github.com/pytest-dev/pytest-asyncio/issues/1279))  ## Notes for Downstream Packagers  -   Tested Python versions include free threaded Python 3.14t ([#1274](https://github.com/pytest-dev/pytest-asyncio/issues/1274)) -   Tests are run in the same |

## Citation

- HTML: https://www.freshcrate.ai/projects/pytest-asyncio
- Markdown: https://www.freshcrate.ai/projects/pytest-asyncio.md
- Dependencies JSON: https://www.freshcrate.ai/api/projects/pytest-asyncio/deps

_Generated by freshcrate.ai. Indexes pypi releases for AI-agent ecosystem packages._
