Skip to main content

curio code is written in the form of async/await, which makes it slightly more difficult to test using normal testing tools. pytest-curio provides useful fixtures and markers to make testing easier.

@pytest.mark.curio
async def test_some_curio_code():
    res = await library.do_something()
    assert b'expected result' == res

pytest-curio has been strongly influenced by pytest-asyncio.

Features

  • fixtures for injecting curio kernel

  • pytest markers for treating tests as curio coroutines

Installation

To install pytest-curio, simply:

$ pip install pytest-curio

This is enough for pytest to pick up pytest-curio.

Fixtures

kernel

Creates and injects a new instance of the default curio kernel. The kernel will be stoped at the end of the test.

Note that just using the kernel fixture won’t make your test function a coroutine. You’ll need to interact with the kernel directly, using methods like kernel.run. See the pytest.mark.curio marker for treating test functions like coroutines.

def test_http_client(kernel):
    result = []
    async def my_coroutine(obj):
        result.append(obj)
    url = 'http://httpbin.org/get'
    task = kernel.run(my_coroutine(url))
    assert url in result

Markers

pytest.mark.curio

Mark your test coroutine with this marker and pytest will execute it as an curio task using the kernel provided by the kernel fixture. See the introductory section for an example.

Release files for pytest-curio 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytest-curio 1.1.0
File Size Uploaded
pytest_curio-1.1.0.tar.gz 26.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pytest-curio 1.1.0
File Interpreter ABI Platform
pytest_curio-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size:34.4 kB

Release files / pytest_curio-1.1.0.tar.gz

Download URL pytest_curio-1.1.0.tar.gz
Size 26.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3dcc9ef052f7efc65d29edd4b2fc1033087ef264047a7332faa7022dce4dbc6d
BLAKE2b-256 checksum
How to use checksums
70e903b12b551e72720db4e0f619db618212ca0c35e6c5c2f1c09354f06d0322
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release files / pytest_curio-1.1.0-py3-none-any.whl

Download URL pytest_curio-1.1.0-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a2ce874c22491c327efcc33800c6f9abd6e5479aa6e9b824852b08783004b2a6
BLAKE2b-256 checksum
How to use checksums
8c024a29dd2b902ae667da6b9d123d7f54a2b344d229b94666a0f80c7d787b9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.2

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.1

1 release file

1.0.0

1 release file

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page