test_zmqstream.py revision 781d71db
1# -*- coding: utf8 -*-
2# Copyright (C) PyZMQ Developers
3# Distributed under the terms of the Modified BSD License.
4
5
6import sys
7import time
8
9from unittest import TestCase
10
11import zmq
12from zmq.eventloop import ioloop, zmqstream
13
14class TestZMQStream(TestCase):
15
16    def setUp(self):
17        self.context = zmq.Context()
18        self.socket = self.context.socket(zmq.REP)
19        self.loop = ioloop.IOLoop.instance()
20        self.stream = zmqstream.ZMQStream(self.socket)
21
22    def tearDown(self):
23        self.socket.close()
24        self.context.term()
25
26    def test_callable_check(self):
27        """Ensure callable check works (py3k)."""
28
29        self.stream.on_send(lambda *args: None)
30        self.stream.on_recv(lambda *args: None)
31        self.assertRaises(AssertionError, self.stream.on_recv, 1)
32        self.assertRaises(AssertionError, self.stream.on_send, 1)
33        self.assertRaises(AssertionError, self.stream.on_recv, zmq)
34
35