diff options
Diffstat (limited to 'tests/test_windows_events.py')
-rw-r--r-- | tests/test_windows_events.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_windows_events.py b/tests/test_windows_events.py index f9b3dd1..73d8fcd 100644 --- a/tests/test_windows_events.py +++ b/tests/test_windows_events.py @@ -1,6 +1,7 @@ import os import sys import unittest +from unittest import mock if sys.platform != 'win32': raise unittest.SkipTest('Windows only') @@ -91,6 +92,18 @@ class ProactorTests(test_utils.TestCase): return 'done' + def test_connect_pipe_cancel(self): + exc = OSError() + exc.winerror = _overlapped.ERROR_PIPE_BUSY + with mock.patch.object(_overlapped, 'ConnectPipe', side_effect=exc) as connect: + coro = self.loop._proactor.connect_pipe('pipe_address') + task = self.loop.create_task(coro) + + # check that it's possible to cancel connect_pipe() + task.cancel() + with self.assertRaises(asyncio.CancelledError): + self.loop.run_until_complete(task) + def test_wait_for_handle(self): event = _overlapped.CreateEvent(None, True, False, None) self.addCleanup(_winapi.CloseHandle, event) |