Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unit test (based on CPython's equivalent)
Co-authored-by: Victor Stinner <victor.stinner@gmail.com>
  • Loading branch information
2 people authored and fantix committed Feb 8, 2021
commit 27cea5dda1a8e4fe2745f422805420621c7dafa8
25 changes: 25 additions & 0 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,31 @@ def throw():
# done-callback for the previous future.
self.loop.run_until_complete(foo(0.2))

def test_run_until_complete_keyboard_interrupt(self):
# Issue #336: run_until_complete() must not schedule a pending
# call to stop() if the future raised a KeyboardInterrupt
async def raise_keyboard_interrupt():
raise KeyboardInterrupt

self.loop._process_events = mock.Mock()

try:
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.assertTrue(func.called)

def test_debug_slow_callbacks(self):
logger = logging.getLogger('asyncio')
self.loop.set_debug(True)
Expand Down