Skip to main content

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

Metadata

Release files for aiounittest 1.5.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 aiounittest 1.5.0
File Size Uploaded
aiounittest-1.5.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aiounittest 1.5.0
File Interpreter ABI Platform
aiounittest-1.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.4 kB

Release files / aiounittest-1.5.0.tar.gz

Download URL aiounittest-1.5.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
3c20ab00909419749061a4cb1a2755f034d10c1f6455adb1f03d7c16dedce711
BLAKE2b-256 checksum
How to use checksums
6f90f0d1ef74a0c022ac64b42d8a278c8f9cbdf2d5049a8f1e7707f4c5f80358
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / aiounittest-1.5.0-py3-none-any.whl

Download URL aiounittest-1.5.0-py3-none-any.whl
Size 7.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30e709730e010c7daa1a0e3ce7398beebd2977d4dbf0a2875b8ed55830ab9d34
BLAKE2b-256 checksum
How to use checksums
20b65a02761969f8bf2c8263ce413c6253cb51a7224559c45608fa8f83e00f3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.5.0 This release

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.1

2 release files

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.0

2 release files

1.0.1

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