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

Uploaded Source

Built Distribution

pytest_asyncio-1.0.0a1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pytest_asyncio-1.0.0a1.tar.gz.

File metadata

  • Download URL: pytest_asyncio-1.0.0a1.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pytest_asyncio-1.0.0a1.tar.gz
Algorithm Hash digest
SHA256 c7b781096da23e618719168acb705c712d5b105ef66cf13e9da77d7868eef81b
MD5 bb5ac0fb069b80680e0a40b121a2cf0d
BLAKE2b-256 754e9a6a67d298f08af76aa9b6df0904d0051d726c63be77acfd56b040a03eff

See more details on using hashes here.

File details

Details for the file pytest_asyncio-1.0.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_asyncio-1.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 aaf3a29d0f37f2408307c159376b2b52f8f185a89420a6cdc68eebe4002d6134
MD5 0795135804fb79f5a2f1275882a4b28b
BLAKE2b-256 bfef89d244a522a7ee48496db7bcce110234d643ca024cc971e05dc20d0fbb32

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