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/master/graph/badge.svg Supported Python versions https://img.shields.io/badge/code%20style-black-000000.svg

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

Uploaded Source

Built Distribution

pytest_asyncio-0.21.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-asyncio-0.21.0.tar.gz
  • Upload date:
  • Size: 29.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.2

File hashes

Hashes for pytest-asyncio-0.21.0.tar.gz
Algorithm Hash digest
SHA256 2b38a496aef56f56b0e87557ec313e11e1ab9276fc3863f6a7be0f1d0e415e1b
MD5 805da62a533c75a9bccadee485f98c27
BLAKE2b-256 85c79db0c6215f12f26b590c24acc96d048e03989315f198454540dff95109cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.21.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f2b3366b7cd501a4056858bd39349d5af19742aed2d81660b7998b6341c7eb9c
MD5 377d117dca023313ed0a12b0a6957494
BLAKE2b-256 6673817ddb37c627338ecbb96486c03fe69a19bef72de1b6bd641aa06fed13f4

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