Run all your asynchronous tests cooperatively.
Project description
Use asyncio (cooperative multitasking) to run your I/O bound test suite efficiently and quickly.
import asyncio
import pytest
@pytest.mark.asyncio_cooperative
async def test_a():
await asyncio.sleep(2)
@pytest.mark.asyncio_cooperative
async def test_b():
await asyncio.sleep(2)
========== 2 passed in 2.05 seconds ==========
Quickstart
pip install pytest-asyncio-cooperative
Compatibility
pytest-asyncio is NOT compatible with this plugin. Please uninstall pytest-asyncio or pass this flag to pytest -p no:asyncio
Goals
Reduce the total run time of I/O bound test suites via cooperative multitasking
Reduce system resource usage via cooperative multitasking
Pros
An I/O bound test suite will run faster (ie. individual tests will take just as long. The total runtime of the entire test suite will be faster)
An I/O bound test suite will use less system resources (ie. only a single thread is used)
Cons
All tests MUST be coroutines (ie. have the async keyword)
Order of tests is not guaranteed (ie. some blocking operations might taken longer and affect the order of test results)
Tests MUST be isolated from each other (ie. NO shared resources, NO mock.patch)
There is NO parallelism, CPU bound tests will NOT get a performance benefit
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
Hashes for pytest-asyncio-cooperative-0.8.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 251ac3b35e3933a98c5ea8c249732819b9b457d403c5e94e088ac72f4e8d43f8 |
|
MD5 | f6e07270fca6e4ade1df7aa7f193099c |
|
BLAKE2b-256 | 2b946e972c3c8e1757f7bdd16e58e3b6ebbf0c34d05fb01a813b9d493ca45a75 |
Hashes for pytest_asyncio_cooperative-0.8.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68dd6a53cc7c09560a41f6a9636729c57a12b5dbeeddea52f97782f96ff4a803 |
|
MD5 | 3be0b5f24c3eeefa5d67f6b8725f8aa5 |
|
BLAKE2b-256 | 7a4293f123a0fc154753c1ad4cd1b40b23fb33febed374eb0768a5137e020d5e |