diff options
| author | Guido van Rossum <guido@python.org> | 2013-11-27 18:37:13 (GMT) |
|---|---|---|
| committer | Guido van Rossum <guido@python.org> | 2013-11-27 18:37:13 (GMT) |
| commit | cced076218b057067294f91f07df784aff8ea774 (patch) | |
| tree | ed3ee7456b4b576270f1b1835825930a74878032 /Lib/test/test_asyncio/test_events.py | |
| parent | 1314ef73d023f10abb6705c386d2a39d692d413b (diff) | |
| download | cpython-cced076218b057067294f91f07df784aff8ea774.zip cpython-cced076218b057067294f91f07df784aff8ea774.tar.gz cpython-cced076218b057067294f91f07df784aff8ea774.tar.bz2 | |
asyncio: Fix get_event_loop() to call set_event_loop() when setting the loop. By Anthony Baire.
Diffstat (limited to 'Lib/test/test_asyncio/test_events.py')
| -rw-r--r-- | Lib/test/test_asyncio/test_events.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py index 6abc724..18411ec 100644 --- a/Lib/test/test_asyncio/test_events.py +++ b/Lib/test/test_asyncio/test_events.py @@ -1599,6 +1599,22 @@ class PolicyTests(unittest.TestCase): self.assertIs(loop, policy.get_event_loop()) loop.close() + def test_get_event_loop_calls_set_event_loop(self): + policy = self.create_policy() + + with unittest.mock.patch.object( + policy, "set_event_loop", + wraps=policy.set_event_loop) as m_set_event_loop: + + loop = policy.get_event_loop() + + # policy._local._loop must be set through .set_event_loop() + # (the unix DefaultEventLoopPolicy needs this call to attach + # the child watcher correctly) + m_set_event_loop.assert_called_with(loop) + + loop.close() + def test_get_event_loop_after_set_none(self): policy = self.create_policy() policy.set_event_loop(None) |
