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.3.tar.gz (54.2 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.3-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest_asyncio-0.25.3.tar.gz
  • Upload date:
  • Size: 54.2 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.3.tar.gz
Algorithm Hash digest
SHA256 fc1da2cf9f125ada7e710b4ddad05518d4cee187ae9412e9ac9271003497f07a
MD5 307961c0f1ad9510aa1cb72715db0bd5
BLAKE2b-256 f2a8ecbc8ede70921dd2f544ab1cadd3ff3bf842af27f87bbdea774c7baa1d38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.25.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9e89518e0f9bd08928f97a3482fdc4e244df17529460bc038291ccaf8f85c7c3
MD5 d18bccad89941bd0e91d02795388ac76
BLAKE2b-256 67173493c5624e48fd97156ebaec380dcaafee9506d7e2c46218ceebbb57d7de

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