Pytest support for asyncio
Project description
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
Built Distribution
File details
Details for the file pytest_asyncio-0.24.0.tar.gz
.
File metadata
- Download URL: pytest_asyncio-0.24.0.tar.gz
- Upload date:
- Size: 49.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276 |
|
MD5 | 510ca6136236bba0f0581aa46060ae03 |
|
BLAKE2b-256 | 526dc6cf50ce320cf8611df7a1254d86233b3df7cc07f9b5f5cbcb82e08aa534 |
File details
Details for the file pytest_asyncio-0.24.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_asyncio-0.24.0-py3-none-any.whl
- Upload date:
- Size: 18.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b |
|
MD5 | 23a90579929f4fb18f604c9a61051d3e |
|
BLAKE2b-256 | 96316607dab48616902f76885dfcf62c08d929796fc3b2d2318faf9fd54dbed9 |