aiounittest
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+) andasyncio.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:
AsyncMockIterator mocking for async for,
futurized mock for coroutines.
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)
| File | Size | Uploaded | |
|---|---|---|---|
| aiounittest-1.5.0.tar.gz | 7.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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
|