mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
Issue #23074: asyncio.get_event_loop() now raises an exception if the thread
has no event loop even if assertions are disabled.
This commit is contained in:
parent
2338156fa4
commit
3a1c738e6c
3 changed files with 6 additions and 6 deletions
|
@ -2252,14 +2252,14 @@ class PolicyTests(unittest.TestCase):
|
|||
def test_get_event_loop_after_set_none(self):
|
||||
policy = asyncio.DefaultEventLoopPolicy()
|
||||
policy.set_event_loop(None)
|
||||
self.assertRaises(AssertionError, policy.get_event_loop)
|
||||
self.assertRaises(RuntimeError, policy.get_event_loop)
|
||||
|
||||
@mock.patch('asyncio.events.threading.current_thread')
|
||||
def test_get_event_loop_thread(self, m_current_thread):
|
||||
|
||||
def f():
|
||||
policy = asyncio.DefaultEventLoopPolicy()
|
||||
self.assertRaises(AssertionError, policy.get_event_loop)
|
||||
self.assertRaises(RuntimeError, policy.get_event_loop)
|
||||
|
||||
th = threading.Thread(target=f)
|
||||
th.start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue