I'm a new with Python 3.6 (was writing a code on Python 2.X a few years) and I'm trying to write some unit tests for my asynchronous code.
I have some asynchronous function like this:
class MyClass(object):
async def my_func(self):
# Doing something with 'await', etc.
Also, I'm writing my test like this:
class MyClassTest(unittest.TestCase):
async def test_my_func(self):
my_class_instance = MyClass()
data = await my_class_instance.my_func()
I hope, this should work, but running this test like this:
notetests -s my_tests.py
Shows me an issue:
/usr/local/Cellar/python3/3.6.2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py:605: RuntimeWarning: coroutine 'MyClassTest.my_func' was never awaited testMethod()
It looks like I have await
and it should work fine, but my data
is not containing any data.
What went wrong?
P.S. I'm not using tornado, that's why there is no sense to add this dependency here.