1d3907f0dSYaroslav Brustinov# Copyright (C) PyZMQ Developers
2d3907f0dSYaroslav Brustinov# Distributed under the terms of the Modified BSD License.
3d3907f0dSYaroslav Brustinov
4d3907f0dSYaroslav Brustinov
5d3907f0dSYaroslav Brustinovfrom unittest import TestCase
6d3907f0dSYaroslav Brustinovimport zmq
7d3907f0dSYaroslav Brustinovfrom zmq.sugar import version
8d3907f0dSYaroslav Brustinov
9d3907f0dSYaroslav Brustinov
10d3907f0dSYaroslav Brustinovclass TestVersion(TestCase):
11d3907f0dSYaroslav Brustinov
12d3907f0dSYaroslav Brustinov    def test_pyzmq_version(self):
13d3907f0dSYaroslav Brustinov        vs = zmq.pyzmq_version()
14d3907f0dSYaroslav Brustinov        vs2 = zmq.__version__
15d3907f0dSYaroslav Brustinov        self.assertTrue(isinstance(vs, str))
16d3907f0dSYaroslav Brustinov        if zmq.__revision__:
17d3907f0dSYaroslav Brustinov            self.assertEqual(vs, '@'.join(vs2, zmq.__revision__))
18d3907f0dSYaroslav Brustinov        else:
19d3907f0dSYaroslav Brustinov            self.assertEqual(vs, vs2)
20d3907f0dSYaroslav Brustinov        if version.VERSION_EXTRA:
21d3907f0dSYaroslav Brustinov            self.assertTrue(version.VERSION_EXTRA in vs)
22d3907f0dSYaroslav Brustinov            self.assertTrue(version.VERSION_EXTRA in vs2)
23d3907f0dSYaroslav Brustinov
24d3907f0dSYaroslav Brustinov    def test_pyzmq_version_info(self):
25d3907f0dSYaroslav Brustinov        info = zmq.pyzmq_version_info()
26d3907f0dSYaroslav Brustinov        self.assertTrue(isinstance(info, tuple))
27d3907f0dSYaroslav Brustinov        for n in info[:3]:
28d3907f0dSYaroslav Brustinov            self.assertTrue(isinstance(n, int))
29d3907f0dSYaroslav Brustinov        if version.VERSION_EXTRA:
30d3907f0dSYaroslav Brustinov            self.assertEqual(len(info), 4)
31d3907f0dSYaroslav Brustinov            self.assertEqual(info[-1], float('inf'))
32d3907f0dSYaroslav Brustinov        else:
33d3907f0dSYaroslav Brustinov            self.assertEqual(len(info), 3)
34d3907f0dSYaroslav Brustinov
35d3907f0dSYaroslav Brustinov    def test_zmq_version_info(self):
36d3907f0dSYaroslav Brustinov        info = zmq.zmq_version_info()
37d3907f0dSYaroslav Brustinov        self.assertTrue(isinstance(info, tuple))
38d3907f0dSYaroslav Brustinov        for n in info[:3]:
39d3907f0dSYaroslav Brustinov            self.assertTrue(isinstance(n, int))
40d3907f0dSYaroslav Brustinov
41d3907f0dSYaroslav Brustinov    def test_zmq_version(self):
42d3907f0dSYaroslav Brustinov        v = zmq.zmq_version()
43d3907f0dSYaroslav Brustinov        self.assertTrue(isinstance(v, str))
44d3907f0dSYaroslav Brustinov
45