~ubuntu-branches/ubuntu/wily/pyzmq/wily

« back to all changes in this revision

Viewing changes to zmq/tests/test_multipart.py

  • Committer: Package Import Robot
  • Author(s): Julian Taylor
  • Date: 2013-02-24 19:23:15 UTC
  • mfrom: (1.2.1) (9 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: package-import@ubuntu.com-20130224192315-qhmwp3m3ymk8r60d
Tags: 2.2.0.1-1
* New upstream release
* relicense debian packaging to LGPL-3
* update watch file to use github directly
  thanks to Bart Martens for the file
* add autopkgtests
* drop obsolete DM-Upload-Allowed
* bump standard to 3.9.4, no changes required

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
#    Copyright (c) 2010 Brian E. Granger
3
 
#
4
 
#    This file is part of pyzmq.
5
 
#
6
 
#    pyzmq is free software; you can redistribute it and/or modify it under
7
 
#    the terms of the Lesser GNU General Public License as published by
8
 
#    the Free Software Foundation; either version 3 of the License, or
9
 
#    (at your option) any later version.
10
 
#
11
 
#    pyzmq is distributed in the hope that it will be useful,
12
 
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
#    Lesser GNU General Public License for more details.
15
 
#
16
 
#    You should have received a copy of the Lesser GNU General Public License
17
 
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
#
 
1
#-----------------------------------------------------------------------------
 
2
#  Copyright (c) 2010-2012 Brian Granger, Min Ragan-Kelley
 
3
#
 
4
#  This file is part of pyzmq
 
5
#
 
6
#  Distributed under the terms of the New BSD License.  The full license is in
 
7
#  the file COPYING.BSD, distributed as part of this software.
 
8
#-----------------------------------------------------------------------------
19
9
 
20
10
#-----------------------------------------------------------------------------
21
11
# Imports
23
13
 
24
14
import zmq
25
15
 
26
 
from zmq.tests import BaseZMQTestCase
 
16
 
 
17
from zmq.tests import BaseZMQTestCase, SkipTest, have_gevent, GreenTest
27
18
 
28
19
#-----------------------------------------------------------------------------
29
20
# Tests
31
22
 
32
23
class TestMultipart(BaseZMQTestCase):
33
24
 
34
 
    def test_xrep_xreq(self):
35
 
        xrep, xreq = self.create_bound_pair(zmq.XREP, zmq.XREQ)
 
25
    def test_router_dealer(self):
 
26
        router, dealer = self.create_bound_pair(zmq.ROUTER, zmq.DEALER)
36
27
 
37
 
        msg1 = 'message1'.encode()
38
 
        xreq.send(msg1)
39
 
        ident = xrep.recv()
40
 
        more = xrep.rcvmore()
 
28
        msg1 = b'message1'
 
29
        dealer.send(msg1)
 
30
        ident = self.recv(router)
 
31
        more = router.rcvmore
41
32
        self.assertEquals(more, True)
42
 
        msg2 = xrep.recv()
 
33
        msg2 = self.recv(router)
43
34
        self.assertEquals(msg1, msg2)
44
 
        more = xrep.rcvmore()
 
35
        more = router.rcvmore
45
36
        self.assertEquals(more, False)
 
37
    
 
38
    def test_basic_multipart(self):
 
39
        a,b = self.create_bound_pair(zmq.PAIR, zmq.PAIR)
 
40
        msg = [ b'hi', b'there', b'b']
 
41
        a.send_multipart(msg)
 
42
        recvd = b.recv_multipart()
 
43
        self.assertEquals(msg, recvd)
46
44
 
 
45
if have_gevent:
 
46
    class TestMultipartGreen(GreenTest, TestMultipart):
 
47
        pass