summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio/test_events.py
diff options
context:
space:
mode:
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()