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

Uploaded Source

Built Distribution

pytest_asyncio-0.23.7-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_asyncio-0.23.7.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for pytest_asyncio-0.23.7.tar.gz
Algorithm Hash digest
SHA256 5f5c72948f4c49e7db4f29f2521d4031f1c27f86e57b046126654083d4770268
MD5 7b1db6be592690347a0a9015afac6040
BLAKE2b-256 13d91dcac9b3fc6eccf8f1e3a657439c11ffc5cf762edd20f65577f832ba248b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.23.7-py3-none-any.whl
Algorithm Hash digest
SHA256 009b48127fbe44518a547bddd25611551b0e43ccdbf1e67d12479f569832c20b
MD5 f0b76fdc43ca041c00343ce404bb9387
BLAKE2b-256 e598947690b1a79af83e584143cb904497caff05bb6016614b38326a81076357

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