Pytest Async Generators
Pytest fixtures for async generators
Usage
Invoke any async generator with await subscribe_to_messages() and then await wait_for_messages() to retrieve the results.
import asyncio
import pytest
from typing import AsyncGenerator, Callable
@pytest.mark.asyncio
async def test_counting(subscribe_to_messages: Callable) -> None:
async def count() -> AsyncGenerator[int, None]:
for n in range(10):
await asyncio.sleep(0.1)
yield n
subscription = await subscribe_to_messages(count())
messages = await subscription.wait_for_messages()
assert messages == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
subscribe_to_messages() can be passed a timeout parameter to control how long to wait for new messages.
Release files for pytest-async-generators 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pytest_async_generators-0.0.4.tar.gz | 1.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pytest_async_generators-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 4.5 kB
Release files / pytest_async_generators-0.0.4.tar.gz
| Download URL | pytest_async_generators-0.0.4.tar.gz |
|---|---|
| Size | 1.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d3ce10c784bcee660c83b256cefa55cfa75f494b282300b4f06ffa2d2cdfacb
|
|
BLAKE2b-256 checksum How to use checksums |
255034e9a8d8d838003b58447c75322710e31deefd252444707a7bc2458637b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.10.0-23-amd64
|
Release files / pytest_async_generators-0.0.4-py3-none-any.whl
| Download URL | pytest_async_generators-0.0.4-py3-none-any.whl |
|---|---|
| Size | 2.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
abef765fbb4e9f01458dc3038a5f7e59913a7eadce892f8a6a881b626f1698ff
|
|
BLAKE2b-256 checksum How to use checksums |
ee9b0d5c182831d9ada1f6c1c48d1b080a322fcf4175656739de75c6719b85ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.4 Linux/5.10.0-23-amd64
|