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