Skip to main content

Test asyncio code more easily.

Project description

aiounittest

image0 image1

Info

This 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)

Installation

Use pip:

pip install aiounitest

Usage

Is as simple as using 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 exposes some other helpers like async_test, futurized to mock coroutines.

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

Uploaded Source

Built Distribution

aiounittest-1.1.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: aiounittest-1.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aiounittest-1.1.0.tar.gz
Algorithm Hash digest
SHA256 226970365eeb4b90c7408091d91e9455acf39d8140125c2e42c49c81c7d2bf64
MD5 381676a95185136a9d7b316bf4208d41
BLAKE2b-256 723446c4512e9ea32b68941a87ecf871545b17d8c7b5362b62d7d2d6a7a553be

See more details on using hashes here.

Provenance

File details

Details for the file aiounittest-1.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for aiounittest-1.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 110351d49e748231813da958ab1ef921924720f03ab34db4a0677a7973ebc20d
MD5 ff12a1ff5f0d2739ff64b375230c7f7c
BLAKE2b-256 e159d7314ee7509f50fa1fdc6c4f4644cfc10c8428af23be88dad0ddf5fe07c5

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