All Projects → kwarunek → aiounittest

kwarunek / aiounittest

Licence: MIT license
Test python asyncio-based code with ease.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to aiounittest

Sanic Ms
基于sanic的微服务基础架构
Stars: ✭ 336 (+533.96%)
Mutual labels:  unittest, asyncio
Asyncpg
A fast PostgreSQL Database Client Library for Python/asyncio.
Stars: ✭ 5,216 (+9741.51%)
Mutual labels:  async-python, asyncio
Uvloop
Ultra fast asyncio event loop.
Stars: ✭ 8,246 (+15458.49%)
Mutual labels:  async-python, asyncio
snekcord
A work-in-progress Discord API wrapper written in Python.
Stars: ✭ 15 (-71.7%)
Mutual labels:  asyncio
mqttools
MQTT version 5.0 client and broker using asyncio
Stars: ✭ 44 (-16.98%)
Mutual labels:  asyncio
website
PySlackers website for invites and learning resources
Stars: ✭ 61 (+15.09%)
Mutual labels:  asyncio
py17track
📦 A simple API to track package info from 17track.com
Stars: ✭ 20 (-62.26%)
Mutual labels:  asyncio
aioppspp
IETF PPSP RFC7574 in Python/asyncio
Stars: ✭ 21 (-60.38%)
Mutual labels:  asyncio
asyncqlio
A fully async ORM for Python 3.5+
Stars: ✭ 25 (-52.83%)
Mutual labels:  asyncio
idataapi-transform
Full async support toolkit for IDataAPI for efficiency work, read data from API/ES/csv/xlsx/json/redis/mysql/mongo/kafka, write to ES/csv/xlsx/json/redis/mysql/mongo/kafka, provide CLI and python API
Stars: ✭ 36 (-32.08%)
Mutual labels:  asyncio
fastapi-users
Ready-to-use and customizable users management for FastAPI
Stars: ✭ 1,920 (+3522.64%)
Mutual labels:  asyncio
telecharm-userbot
A powerful, cool and well-made userbot for your Telegram profile, with promising extension capabilities.
Stars: ✭ 17 (-67.92%)
Mutual labels:  asyncio
unigen
A unit test generator for PHP
Stars: ✭ 22 (-58.49%)
Mutual labels:  unittest
asynchronous
A D port of Python's asyncio library
Stars: ✭ 35 (-33.96%)
Mutual labels:  asyncio
aiorwlock
Read/Write Lock - synchronization primitive for asyncio
Stars: ✭ 90 (+69.81%)
Mutual labels:  asyncio
glQiwiApi
The ultrarapid and multifunctional wrapper over QIWI and YooMoney
Stars: ✭ 44 (-16.98%)
Mutual labels:  asyncio
trualias
Mentally computable verification codes for email aliases implemented as a postfix tcp table or milter; uses asyncio.
Stars: ✭ 33 (-37.74%)
Mutual labels:  asyncio
flake8-assertive
Flake8 unittest assert method checker
Stars: ✭ 30 (-43.4%)
Mutual labels:  unittest
memoize
Caching library for asynchronous Python applications.
Stars: ✭ 53 (+0%)
Mutual labels:  asyncio
distex
Distributed process pool for Python
Stars: ✭ 101 (+90.57%)
Mutual labels:  asyncio

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].