return value
def _wrap_in_coroutine(self, obj):
-
@asyncio.coroutine
def wrapper():
future = asyncio.ensure_future(self.func(obj))
import sys
# Whether "import asyncio" works
-has_asyncio = (sys.version_info[0] == 3 and sys.version_info[1] >= 4)
+has_asyncio = sys.version_info[0] == 3 and sys.version_info[1] >= 4
# Whether the async and await keywords work
-has_async_await = (sys.version_info[0] == 3 and sys.version_info[1] >= 5)
+has_async_await = sys.version_info[0] == 3 and sys.version_info[1] >= 5
print("conftest.py", has_asyncio, has_async_await)
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.7"
+ "Programming Language :: Python :: 3.7",
],
)
from freezegun import freeze_time
import cached_property
-def unittest_run_loop(f):
+def unittest_run_loop(f):
def wrapper(*args, **kwargs):
coro = asyncio.coroutine(f)
future = coro(*args, **kwargs)
return wrapper
+
def CheckFactory(cached_property_decorator, threadsafe=False):
"""
Create dynamically a Check class whose add_cached method is decorated by
"""
class Check(object):
-
def __init__(self):
self.control_total = 0
self.cached_total = 0
return Check
+
class TestCachedProperty(unittest.TestCase):
"""Tests for cached_property"""
@unittest_run_loop
async def test_none_cached_property(self):
-
class Check(object):
-
def __init__(self):
self.cached_total = None
async def add_cached(self):
return self.cached_total
- await self.assert_cached(Check(), None)
\ No newline at end of file
+ await self.assert_cached(Check(), None)
"""
class Check(object):
-
def __init__(self):
self.control_total = 0
self.cached_total = 0
self.assert_cached(check, 2)
def test_none_cached_property(self):
-
class Check(object):
-
def __init__(self):
self.cached_total = None
def unittest_run_loop(f):
-
def wrapper(*args, **kwargs):
coro = asyncio.coroutine(f)
future = coro(*args, **kwargs)
"""
class Check(object):
-
def __init__(self):
self.control_total = 0
self.cached_total = 0
@unittest_run_loop
@asyncio.coroutine
def test_none_cached_property(self):
-
class Check(object):
-
def __init__(self):
self.cached_total = None