/opt/imh-python/lib/python3.9/site-packages/zmq/tests
NameSizeModeActions
asyncio/-0755rm
__pycache__/-0755rm
conftest.py3660644editdlrm
test_auth.py207120644editdlrm
test_cffi_backend.py94810644editdlrm
test_constants.py45700644editdlrm
test_context.py120270644editdlrm
test_cython.py10480644editdlrm
test_decorators.py94950644editdlrm
test_device.py61690644editdlrm
test_draft.py14710644editdlrm
test_error.py12600644editdlrm
test_etc.py5250644editdlrm
test_future.py111590644editdlrm
test_imports.py18050644editdlrm
test_includes.py10130644editdlrm
test_ioloop.py39650644editdlrm
test_log.py66970644editdlrm
test_message.py110910644editdlrm
test_monitor.py30440644editdlrm
test_monqueue.py82230644editdlrm
test_multipart.py9440644editdlrm
test_pair.py12600644editdlrm
test_poll.py72600644editdlrm
test_proxy_steerable.py39220644editdlrm
test_pubsub.py10890644editdlrm
test_reqrep.py18410644editdlrm
test_retry_eintr.py29600644editdlrm
test_security.py81410644editdlrm
test_socket.py216530644editdlrm
test_ssh.py2340644editdlrm
test_version.py13340644editdlrm
test_win32_shim.py17410644editdlrm
test_z85.py22320644editdlrm
test_zmqstream.py24390644editdlrm
__init__.py63820644editdlrm
Edit: /opt/imh-python/lib/python3.9/site-packages/zmq/tests/test_zmqstream.py (2439B)
# -*- coding: utf8 -*- # Copyright (C) PyZMQ Developers # Distributed under the terms of the Modified BSD License. from __future__ import absolute_import try: import asyncio except ImportError: asyncio = None from unittest import TestCase import pytest import zmq try: import tornado from tornado import gen from zmq.eventloop import ioloop, zmqstream except ImportError: tornado = None class TestZMQStream(TestCase): def setUp(self): if tornado is None: pytest.skip() if asyncio: asyncio.set_event_loop(asyncio.new_event_loop()) self.context = zmq.Context() self.loop = ioloop.IOLoop() self.loop.make_current() self.push = zmqstream.ZMQStream(self.context.socket(zmq.PUSH)) self.pull = zmqstream.ZMQStream(self.context.socket(zmq.PULL)) port = self.push.bind_to_random_port('tcp://127.0.0.1') self.pull.connect('tcp://127.0.0.1:%i' % port) self.stream = self.push def tearDown(self): self.loop.close(all_fds=True) self.context.term() ioloop.IOLoop.clear_current() def run_until_timeout(self, timeout=10): timed_out = [] @gen.coroutine def sleep_timeout(): yield gen.sleep(timeout) timed_out[:] = ['timed out'] self.loop.stop() self.loop.add_callback(lambda : sleep_timeout()) self.loop.start() assert not timed_out def test_callable_check(self): """Ensure callable check works (py3k).""" self.stream.on_send(lambda *args: None) self.stream.on_recv(lambda *args: None) self.assertRaises(AssertionError, self.stream.on_recv, 1) self.assertRaises(AssertionError, self.stream.on_send, 1) self.assertRaises(AssertionError, self.stream.on_recv, zmq) def test_on_recv_basic(self): sent = [b'basic'] def callback(msg): assert msg == sent self.loop.stop() self.loop.add_callback(lambda : self.push.send_multipart(sent)) self.pull.on_recv(callback) self.run_until_timeout() def test_on_recv_wake(self): sent = [b'wake'] def callback(msg): assert msg == sent self.loop.stop() self.pull.on_recv(callback) self.loop.call_later(1, lambda : self.push.send_multipart(sent)) self.run_until_timeout()