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

Uploaded Source

Built Distribution

aiounittest-1.4.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aiounittest-1.4.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for aiounittest-1.4.0.tar.gz
Algorithm Hash digest
SHA256 5bd6b507a0df4f3497340fce3f6d41b8e558f5c0ad266efc7cebe5bc41c6211b
MD5 b89fde13b83e90061d28f71008b3d7a5
BLAKE2b-256 68a940d4ff7c8b472bb79b2cbcdba7e8e5f027f0469593337a39d0401ea3342b

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: aiounittest-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

File hashes

Hashes for aiounittest-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c47c5a87f5bba67ee7a0d593422083266db0800aea48705b768c4e3f51d9ed4a
MD5 332d72f6aca7a5b2a761b159c4c11ad9
BLAKE2b-256 ab162594ad0f3c02aec89104d810fee905bc490f49a5bc10eab5d4e5cf7167d7

See more details on using hashes here.

Provenance

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