diff options
author | 2017-02-01 21:13:23 +0200 | |
---|---|---|
committer | 2017-02-02 14:26:12 +0200 | |
commit | 781d71db20b0c5acbe940eff1b1ef2f1b765ce54 (patch) | |
tree | 444ef9944a789eaf7d51729d8e84f0b1ab70bda4 /scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py | |
parent | 7b39a77194c736194b40a40fdd19928b98310959 (diff) |
zmq os independent
Change-Id: Iaf5a782be4db26a979a7535454719e8e62b5969a
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py')
-rw-r--r-- | scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py b/scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py new file mode 100644 index 00000000..a2eee14a --- /dev/null +++ b/scripts/external_libs/pyzmq-14.5.0/python3/ucs4/64bit/zmq/tests/test_error.py @@ -0,0 +1,43 @@ +# -*- coding: utf8 -*- +# Copyright (C) PyZMQ Developers +# Distributed under the terms of the Modified BSD License. + +import sys +import time + +import zmq +from zmq import ZMQError, strerror, Again, ContextTerminated +from zmq.tests import BaseZMQTestCase + +if sys.version_info[0] >= 3: + long = int + +class TestZMQError(BaseZMQTestCase): + + def test_strerror(self): + """test that strerror gets the right type.""" + for i in range(10): + e = strerror(i) + self.assertTrue(isinstance(e, str)) + + def test_zmqerror(self): + for errno in range(10): + e = ZMQError(errno) + self.assertEqual(e.errno, errno) + self.assertEqual(str(e), strerror(errno)) + + def test_again(self): + s = self.context.socket(zmq.REP) + self.assertRaises(Again, s.recv, zmq.NOBLOCK) + self.assertRaisesErrno(zmq.EAGAIN, s.recv, zmq.NOBLOCK) + s.close() + + def atest_ctxterm(self): + s = self.context.socket(zmq.REP) + t = Thread(target=self.context.term) + t.start() + self.assertRaises(ContextTerminated, s.recv, zmq.NOBLOCK) + self.assertRaisesErrno(zmq.TERM, s.recv, zmq.NOBLOCK) + s.close() + t.join() + |