Skip to main content

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.

Tests Status PYPI Version Python Versions

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pytest_aio-0.1.3-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pytest_aio-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_aio-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.6

File hashes

Hashes for pytest_aio-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d04d7e5f4b40c0305728aeae0afde41f62c4899b5b265f28cefc73af405ea174
MD5 0f0b2092109eebff07c3edbc9ca157c1
BLAKE2b-256 fd7d7c7cc8c5cbbe91ee8c602d16c04f5120bc58cbb88140e26aa357566b6803

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page