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.1.tar.gz (44.0 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.23.1-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pytest-asyncio-0.23.1.tar.gz
  • Upload date:
  • Size: 44.0 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.1.tar.gz
Algorithm Hash digest
SHA256 2d06468de455e7d4302e670a583d1a127d57ac2b09c95164a895b88c7a1e5178
MD5 cbaeb8f35febe8d0bd921264981812ca
BLAKE2b-256 04f87cd00342d8effd5a63c2feaba2a70a6c61adb7f12d4983db836ee21a25b5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pytest_asyncio-0.23.1-py3-none-any.whl
Algorithm Hash digest
SHA256 044ac9167e655f2462097e21cc9a29c9385674ea4fcc34677f1cc1ca35f3cd39
MD5 2ff6ad71bc28afe83d90376cf5de2f6a
BLAKE2b-256 96e3d80fe9f85b4ab6152c294e295ca20be5e2b637e476a8124528db53afb730

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