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

Uploaded Source

Built Distribution

pytest_asyncio-0.23.2-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file pytest-asyncio-0.23.2.tar.gz.

File metadata

  • Download URL: pytest-asyncio-0.23.2.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pytest-asyncio-0.23.2.tar.gz
Algorithm Hash digest
SHA256 c16052382554c7b22d48782ab3438d5b10f8cf7a4bdcae7f0f67f097d95beecc
MD5 4214733f4fb204f7cb5bb29b1fda5d3c
BLAKE2b-256 1e4a9ed4762a08facf8dfb2e31b0393913e3dce391a7735e0965c0f2e66f0938

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.23.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea9021364e32d58f0be43b91c6233fb8d2224ccef2398d6837559e587682808f
MD5 974f1ce37b1056259895d9ca16b6301f
BLAKE2b-256 4ad447e991d09385ba7541e9bfdbbf49ff65d5e99400ef5590792021e5b21f40

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