'test sending unicode objects'

def test_send_unicode(self):

    (a, b) = self.create_bound_pair(zmq.PAIR, zmq.PAIR)
    self.sockets.extend([a, b])
    u = '\xc3\xa7\xcf\x80\xc2\xa7'
    if (str is not unicode):
        u = u.decode('utf8')
    self.assertRaises(TypeError, a.send, u, copy=False)
    self.assertRaises(TypeError, a.send, u, copy=True)
    a.send_unicode(u)
    s = b.recv()
    self.assertEqual(s, u.encode('utf8'))
    self.assertEqual(s.decode('utf8'), u)
    a.send_unicode(u, encoding='utf16')
    s = b.recv_unicode(encoding='utf16')
    self.assertEqual(s, u)
