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.5.0.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiounittest-1.5.0.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for aiounittest-1.5.0.tar.gz
Algorithm Hash digest
SHA256 3c20ab00909419749061a4cb1a2755f034d10c1f6455adb1f03d7c16dedce711
MD5 a0011254bc26271b84c3f22d8afa9223
BLAKE2b-256 6f90f0d1ef74a0c022ac64b42d8a278c8f9cbdf2d5049a8f1e7707f4c5f80358

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for aiounittest-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30e709730e010c7daa1a0e3ce7398beebd2977d4dbf0a2875b8ed55830ab9d34
MD5 3515ee3dd82b96a804cd20ca817b22a0
BLAKE2b-256 20b65a02761969f8bf2c8263ce413c6253cb51a7224559c45608fa8f83e00f3a

See more details on using hashes here.

Supported by

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