summaryrefslogtreecommitdiffstats
path: root/external_libs/python/zmq/tests/test_win32_shim.py
diff options
context:
space:
mode:
authorDan Klein <danklei@cisco.com>2015-08-26 18:16:09 +0300
committerDan Klein <danklei@cisco.com>2015-08-26 18:16:09 +0300
commitf8ac9d14a989c8cf1535e16165551dfa370b0b74 (patch)
tree43e396eb5d096ad74ec02afeccf8995a4d241a0f /external_libs/python/zmq/tests/test_win32_shim.py
parentcdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (diff)
parent53f0e28d7f30c7175cbb15884c309613593859d8 (diff)
Merge branch 'master' into dan_stateless
Diffstat (limited to 'external_libs/python/zmq/tests/test_win32_shim.py')
-rw-r--r--external_libs/python/zmq/tests/test_win32_shim.py56
1 files changed, 0 insertions, 56 deletions
diff --git a/external_libs/python/zmq/tests/test_win32_shim.py b/external_libs/python/zmq/tests/test_win32_shim.py
deleted file mode 100644
index 55657bda..00000000
--- a/external_libs/python/zmq/tests/test_win32_shim.py
+++ /dev/null
@@ -1,56 +0,0 @@
-from __future__ import print_function
-
-import os
-
-from functools import wraps
-from zmq.tests import BaseZMQTestCase
-from zmq.utils.win32 import allow_interrupt
-
-
-def count_calls(f):
- @wraps(f)
- def _(*args, **kwds):
- try:
- return f(*args, **kwds)
- finally:
- _.__calls__ += 1
- _.__calls__ = 0
- return _
-
-
-class TestWindowsConsoleControlHandler(BaseZMQTestCase):
-
- def test_handler(self):
- @count_calls
- def interrupt_polling():
- print('Caught CTRL-C!')
-
- if os.name == 'nt':
- from ctypes import windll
- from ctypes.wintypes import BOOL, DWORD
-
- kernel32 = windll.LoadLibrary('kernel32')
-
- # <http://msdn.microsoft.com/en-us/library/ms683155.aspx>
- GenerateConsoleCtrlEvent = kernel32.GenerateConsoleCtrlEvent
- GenerateConsoleCtrlEvent.argtypes = (DWORD, DWORD)
- GenerateConsoleCtrlEvent.restype = BOOL
-
- try:
- # Simulate CTRL-C event while handler is active.
- with allow_interrupt(interrupt_polling):
- result = GenerateConsoleCtrlEvent(0, 0)
- if result == 0:
- raise WindowsError
- except KeyboardInterrupt:
- pass
- else:
- self.fail('Expecting `KeyboardInterrupt` exception!')
-
- # Make sure our handler was called.
- self.assertEqual(interrupt_polling.__calls__, 1)
- else:
- # On non-Windows systems, this utility is just a no-op!
- with allow_interrupt(interrupt_polling):
- pass
- self.assertEqual(interrupt_polling.__calls__, 0)