Skip to main content

Pytest support for asyncio

Project description

https://img.shields.io/pypi/v/pytest-asyncio.svg https://github.com/pytest-dev/pytest-asyncio/workflows/CI/badge.svg https://codecov.io/gh/pytest-dev/pytest-asyncio/branch/main/graph/badge.svg Supported Python versions Matrix chat room: #pytest-asyncio

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:

@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.

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:

$ 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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_asyncio-0.25.2.tar.gz (54.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_asyncio-0.25.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file pytest_asyncio-0.25.2.tar.gz.

File metadata

  • Download URL: pytest_asyncio-0.25.2.tar.gz
  • Upload date:
  • Size: 54.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for pytest_asyncio-0.25.2.tar.gz
Algorithm Hash digest
SHA256 3f8ef9a98f45948ea91a0ed3dc4268b5326c0e7bce73892acc654df4262ad45f
MD5 c00782dd936f55366c536a41184ef04a
BLAKE2b-256 72dfadcc0d60f1053d74717d21d58c0048479e9cab51464ce0d2965b086bd0e2

See more details on using hashes here.

File details

Details for the file pytest_asyncio-0.25.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_asyncio-0.25.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0d0bb693f7b99da304a0634afc0a4b19e49d5e0de2d670f38dc4bfa5727c5075
MD5 956b061be5d42b223eb55645466998e6
BLAKE2b-256 61d8defa05ae50dcd6019a95527200d3b3980043df5aa445d40cb0ef9f7f98ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page