Since Python 3.8 unittest comes with the IsolatedAsyncioTestCase function, designed for this purpose.
from unittest import IsolatedAsyncioTestCase
class Test(IsolatedAsyncioTestCase):
async def test_functionality(self):
result = await functionality()
self.assertEqual(expected, result)
Related Contents:
- How does asyncio actually work?
- How to limit concurrency with Python asyncio?
- How can I periodically execute a function with asyncio?
- Python 3.7 – asyncio.sleep() and time.sleep()
- multiprocessing vs multithreading vs asyncio in Python 3
- How to use asyncio with existing blocking library?
- How unique is Python’s id()?
- asyncio.sleep() vs time.sleep()
- How do I run all Python unit tests in a directory?
- asyncio.sleep() vs time.sleep() in Python
- How to call an async function without await?
- Simplest async/await example possible in Python
- multiprocessing vs multithreading vs asyncio
- Python Mocking a function from an imported module
- asyncio.ensure_future vs. BaseEventLoop.create_task vs. simple coroutine?
- Using asyncio.Queue for producer-consumer flow
- How to set class attribute with await in __init__
- How can I wrap a synchronous function in an async coroutine?
- Python: Write unittest for console print
- Does asyncio supports asynchronous I/O for file operations?
- aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host stackoverflow.com:443 ssl:default [Connect call failed (‘151.101.193.69’, 443)]
- How to combine Celery with asyncio?
- How can I await inside future-like object’s __await__?
- How to pass arguments to a Button command in Tkinter?
- Concatenate strings from several rows using Pandas groupby
- TypeError: unsupported operand type(s) for -: ‘str’ and ‘int’
- What is setup.py?
- What is the purpose of “pip install –user …”?
- Local (?) variable referenced before assignment [duplicate]
- Python webbrowser.open() to open Chrome browser
- Converting String to Int using try/except in Python
- Facebook JSON badly encoded
- How to activate virtualenv in Linux?
- How to install pip for Python 3 on Mac OS X?
- Set up Python 3 build system with Sublime Text 3
- How to Open a file through python
- How to suppress or capture the output of subprocess.run()?
- Backporting Python 3 open(encoding=”utf-8″) to Python 2
- How to redirect with post data (Django)
- How can I call an async function without await?
- Importing class from another file [duplicate]
- Python library ‘unittest’: Generate multiple tests programmatically [duplicate]
- pandas.io.json.json_normalize with very nested json
- Nested inlines in the Django admin?
- how to test if a variable is pd.NaT?
- Backwards-compatible input calls in Python
- python 3 print generator
- Mocking a class: Mock() or patch()?
- Name not defined in type annotation [duplicate]
- Calling Python script from C++ and using its output