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.23.8.tar.gz (46.9 kB view details)

Uploaded Source

Built Distribution

pytest_asyncio-0.23.8-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_asyncio-0.23.8.tar.gz
  • Upload date:
  • Size: 46.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for pytest_asyncio-0.23.8.tar.gz
Algorithm Hash digest
SHA256 759b10b33a6dc61cce40a8bd5205e302978bbbcc00e279a8b61d9a6a3c82e4d3
MD5 d6c58f06d90a95bdd30ef20ef9fbff88
BLAKE2b-256 deb40b378b7bf26a8ae161c3890c0b48a91a04106c5713ce81b4b080ea2f4f18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.23.8-py3-none-any.whl
Algorithm Hash digest
SHA256 50265d892689a5faefb84df80819d1ecef566eb3549cf915dfb33569359d1ce2
MD5 de06a164170686e12261ef8fc0a6cfbe
BLAKE2b-256 ee8262e2d63639ecb0fbe8a7ee59ef0bc69a4669ec50f6d3459f74ad4e4189a2

See more details on using hashes here.

Supported by

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