summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yury@magic.io>2016-11-04 18:30:41 (GMT)
committerYury Selivanov <yury@magic.io>2016-11-04 18:30:41 (GMT)
commita494e34ca1167667f6b53f34d1452f5621ee0e46 (patch)
tree60d89ce8fd0f48b198b9edabd82f61f31093891d /Lib/test/test_asyncio/test_events.py
parentca2d8be4ba3c0ab25fd42567df52300b560aadc5 (diff)
parent69312fa4a2712b3ff37e473c833a42162aa9b5cd (diff)
downloadcpython-a494e34ca1167667f6b53f34d1452f5621ee0e46.zip
cpython-a494e34ca1167667f6b53f34d1452f5621ee0e46.tar.gz
cpython-a494e34ca1167667f6b53f34d1452f5621ee0e46.tar.bz2
Merge 3.6 (issue #28613)
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
-rw-r--r--Lib/test/test_asyncio/test_events.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index d8946e3..4c18300 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -2233,6 +2233,7 @@ def noop(*args, **kwargs):
class HandleTests(test_utils.TestCase):
def setUp(self):
+ super().setUp()
self.loop = mock.Mock()
self.loop.get_debug.return_value = True
@@ -2411,6 +2412,7 @@ class HandleTests(test_utils.TestCase):
class TimerTests(unittest.TestCase):
def setUp(self):
+ super().setUp()
self.loop = mock.Mock()
def test_hash(self):
@@ -2719,6 +2721,27 @@ class PolicyTests(unittest.TestCase):
self.assertIs(policy, asyncio.get_event_loop_policy())
self.assertIsNot(policy, old_policy)
+ def test_get_event_loop_returns_running_loop(self):
+ class Policy(asyncio.DefaultEventLoopPolicy):
+ def get_event_loop(self):
+ raise NotImplementedError
+
+ loop = None
+
+ old_policy = asyncio.get_event_loop_policy()
+ try:
+ asyncio.set_event_loop_policy(Policy())
+ loop = asyncio.new_event_loop()
+
+ async def func():
+ self.assertIs(asyncio.get_event_loop(), loop)
+
+ loop.run_until_complete(func())
+ finally:
+ asyncio.set_event_loop_policy(old_policy)
+ if loop is not None:
+ loop.close()
+
if __name__ == '__main__':
unittest.main()