mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-08-02 03:00:17 +03:00
Refactor coroutine provider tests
This commit is contained in:
parent
06526d9457
commit
891e356197
|
@ -1,9 +1,6 @@
|
||||||
"""Dependency injector coroutine providers unit tests."""
|
"""Dependency injector coroutine providers unit tests."""
|
||||||
|
|
||||||
try:
|
|
||||||
import asyncio
|
import asyncio
|
||||||
except ImportError:
|
|
||||||
asyncio = None
|
|
||||||
|
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
|
@ -13,7 +10,6 @@ from dependency_injector import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if asyncio:
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _example(arg1, arg2, arg3, arg4):
|
def _example(arg1, arg2, arg3, arg4):
|
||||||
future = asyncio.Future()
|
future = asyncio.Future()
|
||||||
|
@ -21,16 +17,14 @@ if asyncio:
|
||||||
yield from future
|
yield from future
|
||||||
return arg1, arg2, arg3, arg4
|
return arg1, arg2, arg3, arg4
|
||||||
|
|
||||||
|
|
||||||
def _run(coro):
|
def _run(coro):
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
return loop.run_until_complete(coro)
|
return loop.run_until_complete(coro)
|
||||||
else:
|
|
||||||
_example = None
|
|
||||||
|
|
||||||
|
|
||||||
class CoroutineTests(unittest.TestCase):
|
class CoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
if asyncio:
|
|
||||||
def test_init_with_coroutine(self):
|
def test_init_with_coroutine(self):
|
||||||
self.assertTrue(providers.Coroutine(_example))
|
self.assertTrue(providers.Coroutine(_example))
|
||||||
|
|
||||||
|
@ -197,7 +191,6 @@ class CoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
class DelegatedCoroutineTests(unittest.TestCase):
|
class DelegatedCoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
if asyncio:
|
|
||||||
def test_inheritance(self):
|
def test_inheritance(self):
|
||||||
self.assertIsInstance(providers.DelegatedCoroutine(_example),
|
self.assertIsInstance(providers.DelegatedCoroutine(_example),
|
||||||
providers.Coroutine)
|
providers.Coroutine)
|
||||||
|
@ -222,7 +215,6 @@ class DelegatedCoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
class AbstractCoroutineTests(unittest.TestCase):
|
class AbstractCoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
if asyncio:
|
|
||||||
def test_inheritance(self):
|
def test_inheritance(self):
|
||||||
self.assertIsInstance(providers.AbstractCoroutine(_example),
|
self.assertIsInstance(providers.AbstractCoroutine(_example),
|
||||||
providers.Coroutine)
|
providers.Coroutine)
|
||||||
|
@ -277,7 +269,6 @@ class AbstractCoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
class CoroutineDelegateTests(unittest.TestCase):
|
class CoroutineDelegateTests(unittest.TestCase):
|
||||||
|
|
||||||
if asyncio:
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.delegated = providers.Coroutine(_example)
|
self.delegated = providers.Coroutine(_example)
|
||||||
self.delegate = providers.CoroutineDelegate(self.delegated)
|
self.delegate = providers.CoroutineDelegate(self.delegated)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user