mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-07-31 10:19:48 +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."""
|
||||
|
||||
try:
|
||||
import asyncio
|
||||
except ImportError:
|
||||
asyncio = None
|
||||
|
||||
import unittest2 as unittest
|
||||
|
||||
|
@ -13,7 +10,6 @@ from dependency_injector import (
|
|||
)
|
||||
|
||||
|
||||
if asyncio:
|
||||
@asyncio.coroutine
|
||||
def _example(arg1, arg2, arg3, arg4):
|
||||
future = asyncio.Future()
|
||||
|
@ -21,16 +17,14 @@ if asyncio:
|
|||
yield from future
|
||||
return arg1, arg2, arg3, arg4
|
||||
|
||||
|
||||
def _run(coro):
|
||||
loop = asyncio.get_event_loop()
|
||||
return loop.run_until_complete(coro)
|
||||
else:
|
||||
_example = None
|
||||
|
||||
|
||||
class CoroutineTests(unittest.TestCase):
|
||||
|
||||
if asyncio:
|
||||
def test_init_with_coroutine(self):
|
||||
self.assertTrue(providers.Coroutine(_example))
|
||||
|
||||
|
@ -197,7 +191,6 @@ class CoroutineTests(unittest.TestCase):
|
|||
|
||||
class DelegatedCoroutineTests(unittest.TestCase):
|
||||
|
||||
if asyncio:
|
||||
def test_inheritance(self):
|
||||
self.assertIsInstance(providers.DelegatedCoroutine(_example),
|
||||
providers.Coroutine)
|
||||
|
@ -222,7 +215,6 @@ class DelegatedCoroutineTests(unittest.TestCase):
|
|||
|
||||
class AbstractCoroutineTests(unittest.TestCase):
|
||||
|
||||
if asyncio:
|
||||
def test_inheritance(self):
|
||||
self.assertIsInstance(providers.AbstractCoroutine(_example),
|
||||
providers.Coroutine)
|
||||
|
@ -277,7 +269,6 @@ class AbstractCoroutineTests(unittest.TestCase):
|
|||
|
||||
class CoroutineDelegateTests(unittest.TestCase):
|
||||
|
||||
if asyncio:
|
||||
def setUp(self):
|
||||
self.delegated = providers.Coroutine(_example)
|
||||
self.delegate = providers.CoroutineDelegate(self.delegated)
|
||||
|
|
Loading…
Reference in New Issue
Block a user