Skip to content

Commit

Permalink
asyncmock utility (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
rjt-gupta authored and rnehra01 committed May 16, 2019
1 parent 2b63cba commit b6ee894
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tanner/utils/asyncmock.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import asyncio
from unittest.mock import Mock


class AsyncMock(Mock): # custom function defined to mock asyncio coroutines

def __call__(self, *args, **kwargs):
sup = super(AsyncMock, self)

async def coro():
return sup.__call__(*args, **kwargs)
return coro()

def __await__(self):
return self().__await__()

0 comments on commit b6ee894

Please # to comment.