Skip to main content

Run all your asynchronous tests cooperatively.

Project description

https://img.shields.io/badge/code%20style-black-000000.svg

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

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


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-cooperative-0.6.0.tar.gz (5.5 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_cooperative-0.6.0-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest-asyncio-cooperative-0.6.0.tar.gz.

File metadata

File hashes

Hashes for pytest-asyncio-cooperative-0.6.0.tar.gz
Algorithm Hash digest
SHA256 860be70a25418eb754e33c8619787d3cc76db1ed2892ffca1e7065379ef387cf
MD5 5b764252fb374393fbb1a4ec246d58f4
BLAKE2b-256 233701d7ec97b6a6393371caf1aaf1ec28d2fe5898414470072585354bee8059

See more details on using hashes here.

File details

Details for the file pytest_asyncio_cooperative-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_asyncio_cooperative-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4b9c831eb2c8fbad884d128c019ab0b8256f417f5c7bcfdcb26c4d45a6b0444
MD5 e322b6e64299fdc705f3528c0c39afbb
BLAKE2b-256 8fdd0979fe6f00e92f25d7d8ab30cc02a0611fdb0950cc50724837efc1db4a44

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