[Python-checkins] Fix `test_run_until_complete_baseexception` test to check for `KeyboardInterrupt` in asyncio (#24477)
kumaraditya303
webhook-mailer at python.org
Thu Dec 8 03:21:20 EST 2022
https://github.com/python/cpython/commit/e8fff515f056737d6d055ea5438b2135863548b1
commit: e8fff515f056737d6d055ea5438b2135863548b1
branch: main
author: Fantix King <fantix.king at gmail.com>
committer: kumaraditya303 <59607654+kumaraditya303 at users.noreply.github.com>
date: 2022-12-08T13:51:04+05:30
summary:
Fix `test_run_until_complete_baseexception` test to check for `KeyboardInterrupt` in asyncio (#24477)
files:
M Lib/test/test_asyncio/test_base_events.py
diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
index 65dd4d42708b..532a7e5385ae 100644
--- a/Lib/test/test_asyncio/test_base_events.py
+++ b/Lib/test/test_asyncio/test_base_events.py
@@ -861,20 +861,15 @@ async def raise_keyboard_interrupt():
self.loop._process_events = mock.Mock()
- try:
+ with self.assertRaises(KeyboardInterrupt):
self.loop.run_until_complete(raise_keyboard_interrupt())
- except KeyboardInterrupt:
- pass
def func():
self.loop.stop()
func.called = True
func.called = False
- try:
- self.loop.call_soon(func)
- self.loop.run_forever()
- except KeyboardInterrupt:
- pass
+ self.loop.call_later(0.01, func)
+ self.loop.run_forever()
self.assertTrue(func.called)
def test_single_selecter_event_callback_after_stopping(self):
More information about the Python-checkins
mailing list