mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-02-12 09:30:46 +03:00
Try fix 3.6 tests
This commit is contained in:
parent
9161b01e97
commit
ff4803d6a5
|
@ -1,7 +1,7 @@
|
||||||
"""Dependency injector coroutine providers unit tests."""
|
"""Dependency injector coroutine providers unit tests."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from asyncio import coroutines, events, tasks
|
from asyncio import coroutines, events
|
||||||
|
|
||||||
import unittest2 as unittest
|
import unittest2 as unittest
|
||||||
|
|
||||||
|
@ -34,35 +34,12 @@ def _run(coro, debug=False):
|
||||||
return loop.run_until_complete(coro)
|
return loop.run_until_complete(coro)
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
_cancel_all_tasks(loop)
|
|
||||||
loop.run_until_complete(loop.shutdown_asyncgens())
|
loop.run_until_complete(loop.shutdown_asyncgens())
|
||||||
finally:
|
finally:
|
||||||
events.set_event_loop(None)
|
events.set_event_loop(None)
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
||||||
|
|
||||||
def _cancel_all_tasks(loop):
|
|
||||||
to_cancel = tasks.all_tasks(loop)
|
|
||||||
if not to_cancel:
|
|
||||||
return
|
|
||||||
|
|
||||||
for task in to_cancel:
|
|
||||||
task.cancel()
|
|
||||||
|
|
||||||
loop.run_until_complete(
|
|
||||||
tasks.gather(*to_cancel, loop=loop, return_exceptions=True))
|
|
||||||
|
|
||||||
for task in to_cancel:
|
|
||||||
if task.cancelled():
|
|
||||||
continue
|
|
||||||
if task.exception() is not None:
|
|
||||||
loop.call_exception_handler({
|
|
||||||
'message': 'unhandled exception during asyncio.run() shutdown',
|
|
||||||
'exception': task.exception(),
|
|
||||||
'task': task,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
class CoroutineTests(unittest.TestCase):
|
class CoroutineTests(unittest.TestCase):
|
||||||
|
|
||||||
def test_init_with_coroutine(self):
|
def test_init_with_coroutine(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user