003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/zmq/tests
usr
/
local
/
lib
/
python3.8
/
site-packages
/
zmq
/
tests
/
📁
..
📄
__init__.py
(7.75 KB)
📁
__pycache__
📄
conftest.py
(40 B)
📄
test_asyncio.py
(15.57 KB)
📄
test_auth.py
(20.72 KB)
📄
test_cffi_backend.py
(8.79 KB)
📄
test_constants.py
(4.49 KB)
📄
test_context.py
(12.1 KB)
📄
test_cython.py
(1.03 KB)
📄
test_decorators.py
(9.4 KB)
📄
test_device.py
(6.02 KB)
📄
test_draft.py
(1.42 KB)
📄
test_error.py
(1.17 KB)
📄
test_etc.py
(545 B)
📄
test_future.py
(10.62 KB)
📄
test_imports.py
(1.76 KB)
📄
test_includes.py
(997 B)
📄
test_ioloop.py
(3.84 KB)
📄
test_log.py
(6.51 KB)
📄
test_message.py
(11.68 KB)
📄
test_monitor.py
(3 KB)
📄
test_monqueue.py
(7.97 KB)
📄
test_multipart.py
(941 B)
📄
test_mypy.py
(1.57 KB)
📄
test_pair.py
(1.24 KB)
📄
test_poll.py
(7.17 KB)
📄
test_proxy_steerable.py
(3.7 KB)
📄
test_pubsub.py
(1.07 KB)
📄
test_reqrep.py
(1.8 KB)
📄
test_retry_eintr.py
(2.88 KB)
📄
test_security.py
(8 KB)
📄
test_socket.py
(23.09 KB)
📄
test_ssh.py
(235 B)
📄
test_version.py
(1.3 KB)
📄
test_win32_shim.py
(1.68 KB)
📄
test_z85.py
(2.15 KB)
📄
test_zmqstream.py
(2.35 KB)
Editing: test_win32_shim.py
from __future__ import print_function import os import time import sys from functools import wraps from pytest import mark 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 _ @mark.new_console class TestWindowsConsoleControlHandler(BaseZMQTestCase): @mark.new_console @mark.skipif(not sys.platform.startswith('win'), reason='Windows only test') def test_handler(self): @count_calls def interrupt_polling(): print('Caught CTRL-C!') 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 # Simulate CTRL-C event while handler is active. try: with allow_interrupt(interrupt_polling) as context: result = GenerateConsoleCtrlEvent(0, 0) # Sleep so that we give time to the handler to # capture the Ctrl-C event. time.sleep(0.5) except KeyboardInterrupt: pass else: if result == 0: raise WindowsError() else: self.fail('Expecting `KeyboardInterrupt` exception!') # Make sure our handler was called. self.assertEqual(interrupt_polling.__calls__, 1)
Upload File
Create Folder