Skip to main content

Test asyncio code more easily.

Project description

aiounittest

image0 image1

Info

The aiounittest is a helper library to ease of your pain (and boilerplate), when writing a test of the asynchronous code (asyncio). You can test:

  • synchronous code (same as the unittest.TestCase)

  • asynchronous code, it supports syntax with async/await (Python 3.5+) and asyncio.coroutine/yield from (Python 3.4)

In the Python 3.8 (release note) and newer consider to use the unittest.IsolatedAsyncioTestCase. Builtin unittest module is now asyncio-featured.

Installation

Use pip:

pip install aiounittest

Usage

It’s as simple as use of unittest.TestCase. Full docs at http://aiounittest.readthedocs.io.

import asyncio
import aiounittest


async def add(x, y):
    await asyncio.sleep(0.1)
    return x + y

class MyTest(aiounittest.AsyncTestCase):

    async def test_async_add(self):
        ret = await add(5, 6)
        self.assertEqual(ret, 11)

    # or 3.4 way
    @asyncio.coroutine
    def test_sleep(self):
        ret = yield from add(5, 6)
        self.assertEqual(ret, 11)

    # some regular test code
    def test_something(self):
        self.assertTrue(True)

Library provides some additional tooling:

License

MIT

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

aiounittest-1.4.2.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

aiounittest-1.4.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file aiounittest-1.4.2.tar.gz.

File metadata

  • Download URL: aiounittest-1.4.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for aiounittest-1.4.2.tar.gz
Algorithm Hash digest
SHA256 1478ec8013c70046569cdc76d541083ca7da362e6513cf29c7ecb51330229bdb
MD5 83a92c6b0bfd91819b2516e3a80e2380
BLAKE2b-256 51c2e53af20ec0850cad9943b989a64254aa4db7e2513d91b661de114aec5032

See more details on using hashes here.

File details

Details for the file aiounittest-1.4.2-py3-none-any.whl.

File metadata

  • Download URL: aiounittest-1.4.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for aiounittest-1.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11634918fbbf09b954d97c74d857835750d025d1cafb675391d0099b8d83665a
MD5 ef1a69c0b3620e2473dd9656ebb73308
BLAKE2b-256 2e44df1984e64e06ba42174835b10d7184ce3e342a8038c6d5a256b4fa739b78

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