From 76382dc8123cdd0b9cb4ec93fc8bfb52c82547df 2014-01-21 15:48:14 From: Doug Blank Date: 2014-01-21 15:48:14 Subject: [PATCH] Added test_send_raw() for issue #4839, see pull request 4840 --- diff --git a/IPython/kernel/zmq/tests/test_session.py b/IPython/kernel/zmq/tests/test_session.py index 36c8d40..6d0fd95 100644 --- a/IPython/kernel/zmq/tests/test_session.py +++ b/IPython/kernel/zmq/tests/test_session.py @@ -287,3 +287,29 @@ class TestSession(SessionTestCase): session = ss.Session(packer='msgpack.packb', unpacker='msgpack.unpackb') self._datetime_test(session) + def test_send_raw(self): + ctx = zmq.Context.instance() + A = ctx.socket(zmq.PAIR) + B = ctx.socket(zmq.PAIR) + A.bind("inproc://test") + B.connect("inproc://test") + + msg = self.session.msg('execute', content=dict(a=10)) + msg_list = [self.session.pack(msg[part]) for part in + ['header', 'parent_header', 'metadata', 'content']] + print("old:", msg_list) + self.session.send_raw(A, msg_list, ident=b'foo') + + ident, new_msg_list = self.session.feed_identities(B.recv_multipart()) + print("new:", new_msg_list) + new_msg = self.session.unserialize(new_msg_list) + self.assertEqual(ident[0], b'foo') + self.assertEqual(new_msg['msg_type'],msg['msg_type']) + self.assertEqual(new_msg['header'],msg['header']) + self.assertEqual(new_msg['parent_header'],msg['parent_header']) + self.assertEqual(new_msg['content'],msg['content']) + self.assertEqual(new_msg['metadata'],msg['metadata']) + + A.close() + B.close() + ctx.term()