aiounittest
===========
|image0|_ |image1|_
.. |image0| image:: https://api.travis-ci.com/kwarunek/aiounittest.svg?branch=master
.. _image0: https://travis-ci.com/kwarunek/aiounittest
.. |image1| image:: https://badge.fury.io/py/aiounittest.svg
.. _image1: https://badge.fury.io/py/aiounittest
Info
====
The `aiounittest` is a helper library to ease of your pain (and boilerplate), when writing a test of the asynchronous code (:code:`asyncio`). You can test:
* synchronous code (same as the :code:`unittest.TestCase`)
* asynchronous code, it supports syntax with :code:`async`/:code:`await` (Python 3.5+) and :code:`asyncio.coroutine`/:code:`yield from` (Python 3.4)
In the Python 3.8 (`release note <https://docs.python.org/3/whatsnew/3.8.html#unittest>`_) and newer consider to use the `unittest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`_. Builtin :code:`unittest` module is now asyncio-featured.
Installation
============
Use pip:
::
pip install aiounittest
Usage
=====
It's as simple as use of :code:`unittest.TestCase`. Full docs at http://aiounittest.readthedocs.io.
.. code-block:: python
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:
* async_test_,
* AsyncMockIterator_ mocking for `async for`,
* futurized_ mock for coroutines.
.. _futurized: http://aiounittest.readthedocs.io/en/latest/futurized.html
.. _async_test: http://aiounittest.readthedocs.io/en/latest/async_test.html
.. _AsyncMockIterator: http://aiounittest.readthedocs.io/en/latest/asyncmockiterator.html
License
=======
MIT
Raw data
{
"_id": null,
"home_page": "https://github.com/kwarunek/aiounittest",
"name": "aiounittest",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "asyncio,async,unittest,coroutine",
"author": "Krzysztof Warunek",
"author_email": "krzysztof@warunek.net",
"download_url": "https://files.pythonhosted.org/packages/51/c2/e53af20ec0850cad9943b989a64254aa4db7e2513d91b661de114aec5032/aiounittest-1.4.2.tar.gz",
"platform": null,
"description": "aiounittest\n===========\n\n|image0|_ |image1|_\n\n.. |image0| image:: https://api.travis-ci.com/kwarunek/aiounittest.svg?branch=master\n.. _image0: https://travis-ci.com/kwarunek/aiounittest\n\n.. |image1| image:: https://badge.fury.io/py/aiounittest.svg\n.. _image1: https://badge.fury.io/py/aiounittest\n\nInfo\n====\n\nThe `aiounittest` is a helper library to ease of your pain (and boilerplate), when writing a test of the asynchronous code (:code:`asyncio`). You can test:\n\n* synchronous code (same as the :code:`unittest.TestCase`)\n* asynchronous code, it supports syntax with :code:`async`/:code:`await` (Python 3.5+) and :code:`asyncio.coroutine`/:code:`yield from` (Python 3.4)\n\n\nIn the Python 3.8 (`release note <https://docs.python.org/3/whatsnew/3.8.html#unittest>`_) and newer consider to use the `unittest.IsolatedAsyncioTestCase <https://docs.python.org/3/library/unittest.html#unittest.IsolatedAsyncioTestCase>`_. Builtin :code:`unittest` module is now asyncio-featured.\n\n\nInstallation\n============\n\nUse pip:\n\n::\n\n pip install aiounittest\n\n\nUsage\n=====\n\nIt's as simple as use of :code:`unittest.TestCase`. Full docs at http://aiounittest.readthedocs.io.\n\n.. code-block:: python\n\n import asyncio\n import aiounittest\n\n\n async def add(x, y):\n await asyncio.sleep(0.1)\n return x + y\n\n class MyTest(aiounittest.AsyncTestCase):\n\n async def test_async_add(self):\n ret = await add(5, 6)\n self.assertEqual(ret, 11)\n\n # or 3.4 way\n @asyncio.coroutine\n def test_sleep(self):\n ret = yield from add(5, 6)\n self.assertEqual(ret, 11)\n\n # some regular test code\n def test_something(self):\n self.assertTrue(True)\n\nLibrary provides some additional tooling:\n\n* async_test_,\n* AsyncMockIterator_ mocking for `async for`,\n* futurized_ mock for coroutines.\n\n.. _futurized: http://aiounittest.readthedocs.io/en/latest/futurized.html\n.. _async_test: http://aiounittest.readthedocs.io/en/latest/async_test.html\n.. _AsyncMockIterator: http://aiounittest.readthedocs.io/en/latest/asyncmockiterator.html\n\nLicense\n=======\n\nMIT\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Test asyncio code more easily.",
"version": "1.4.2",
"split_keywords": [
"asyncio",
"async",
"unittest",
"coroutine"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "ef1a69c0b3620e2473dd9656ebb73308",
"sha256": "11634918fbbf09b954d97c74d857835750d025d1cafb675391d0099b8d83665a"
},
"downloads": -1,
"filename": "aiounittest-1.4.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ef1a69c0b3620e2473dd9656ebb73308",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 6986,
"upload_time": "2022-06-13T13:11:02",
"upload_time_iso_8601": "2022-06-13T13:11:02.100930Z",
"url": "https://files.pythonhosted.org/packages/2e/44/df1984e64e06ba42174835b10d7184ce3e342a8038c6d5a256b4fa739b78/aiounittest-1.4.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "83a92c6b0bfd91819b2516e3a80e2380",
"sha256": "1478ec8013c70046569cdc76d541083ca7da362e6513cf29c7ecb51330229bdb"
},
"downloads": -1,
"filename": "aiounittest-1.4.2.tar.gz",
"has_sig": false,
"md5_digest": "83a92c6b0bfd91819b2516e3a80e2380",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5812,
"upload_time": "2022-06-13T13:11:03",
"upload_time_iso_8601": "2022-06-13T13:11:03.239015Z",
"url": "https://files.pythonhosted.org/packages/51/c2/e53af20ec0850cad9943b989a64254aa4db7e2513d91b661de114aec5032/aiounittest-1.4.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-06-13 13:11:03",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "kwarunek",
"github_project": "aiounittest",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"lcname": "aiounittest"
}