Pytest plugin for testing async python code
Project description
pytest-aio
pytest-aio – Is a simple pytest plugin for testing async python code
The plugin supports all popular python async libraries: (Asyncio, Trio, Curio)
pytest-aio has been strongly influenced by AnyIO. Since 2021-02-09 AnyIO has dropped support for Curio, so the plugin has been created.
Requirements
python >= 3.7
Installation
pytest-aio should be installed using pip:
pip install pytest-aio
optionally extras are available:
pip install pytest-aio[curio,trio]
Usage
When installed the plugin run all your async test functions/fixtures.
async def test_async():
assert True
By default each test function will be run with asyncio, trio, curio libraries consistently. But you can customise the libraries for all your tests creating the fixture:
# Run all tests with Asyncio/Trio only
@pytest.fixture(params=['asyncio', 'trio'])
def aiolib(request):
assert request.param
Or customize an async backend for a test only:
@pytest.mark.parametrize('aiolib', ['asyncio'])
async def only_with_asyncio():
await asyncio.sleep(1)
assert True
Bug tracker
If you have any suggestions, bug reports or annoyances please report them to the issue tracker at https://github.com/klen/asgi-tools/issues
Contributing
Development of the project happens at: https://github.com/klen/pytest-aio
License
Licensed under a MIT license.
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 Distributions
Built Distribution
Hashes for pytest_aio-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d623a8bf8c4f5c00f55767706f68b8d0b774fd188f05df62631560b0204f292 |
|
MD5 | a005c92e1d98149a1f9fa108c273b3dd |
|
BLAKE2b-256 | c59eb2187ae845f7a98a68a15df20496a8815bbf16b3d240f59cf054f722a023 |