asynctest
asynctest copied to clipboard
Enhance the standard unittest package with features for testing asyncio libraries
We were exploring aio_pika and we had this test: ``` class OurTest(TestCase): async def test_one(self): with asynctest.mock.patch('aio_pika.robust_connect') as mcr: await AdapterClass.create(**options) #options is a dict declared prior to test class...
It would be very convenient if we could use the code for manually controlling event loop time within a plain test function as well (e.g. via some 'TimeSkipper' class that's...
Hi, Sorry if this is documented somewhere, but is there a way to force either Mock, MagicMock or CoroutineMock to always return CoroutineMock for method calls? I understand that this...
The name CoroutineMock is confusing (see #100, #101, etc) as it's the mock of a coroutine function, not a coroutine itself. CoroutineMock should be renamed to CoroutineFunctionMock. CoroutineMock will be...
Currently, the behavior when calling a CoroutineMock with a coroutine as side_effect is undefined. It raises an exception with Python 3.6 and seems to run the coroutine with Python 3.5...
Asynchronous generators are defined by [PEP 525](https://www.python.org/dev/peps/pep-0525/) and supported since Python 3.6 Unfortunately the syntax change (yielding from a coroutine) is not backward compatible, previous versions of Python will raise...
While testing with uvloop, the @fail_on decorator seems to rely on the internals of the default asyncio loop: ```python import asyncio import asynctest import uvloop # make calls to asyncio.get_event_loop()...
Now that CoroutineMock relies on the loop for some features, we should let the user specify which loop shall be used. CoroutineMock(loop=None) # default, in this case, get_event_loop() is called...
Let's use py.test and codecoverage (with support for branching). It can be configured like this: https://github.com/Kentzo/async_app/blob/master/setup.py#L15-L27 https://github.com/Kentzo/async_app/blob/master/setup.py#L50 https://github.com/Kentzo/async_app/blob/master/setup.cfg#L25-L27
Docs say that classes extending asynctest.TestCase can have either a sync or async. Because the default implementation is sync, it is impossible to write mixins that implement setUp and call...