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

Uploaded Source

Built Distribution

pytest_asyncio-0.23.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-asyncio-0.23.0.tar.gz
  • Upload date:
  • Size: 43.7 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.0.tar.gz
Algorithm Hash digest
SHA256 236e89745b8be43b3b473640b523f26fe3c62a2afa7548e38532e9f201d22fc3
MD5 502605b040f0af78ff5c5e29d71b8c31
BLAKE2b-256 dbf38fb382a48bded867e16e4f793ff69cd89a4e9c845c6173d28fcd34a9f12f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.23.0-py3-none-any.whl
Algorithm Hash digest
SHA256 91ef405536331eb9971511aeb08225869985d800cf491015f7407044e7d1d7f8
MD5 786e4d2c6858f3905a38696cc19e1f84
BLAKE2b-256 5465a4bf83365294e6aba4936aef0e6d7b87cfc5846d448392a980a862104179

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