summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-12-27 06:37:18 -0500
committerimarom <imarom@cisco.com>2015-12-27 07:27:36 -0500
commitaec3c8f4a0fe4da9a964a051d86fae808f336a55 (patch)
treeb9cdd5fb06b55141a234d83c5be3f72e4a093c78 /scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py
parent9d1cd91825d48a97ca0ea21fa7bd34900f6c7450 (diff)
provide a CEL 5.9 a way to run trex-console
Diffstat (limited to 'scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py')
-rw-r--r--scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py b/scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py
new file mode 100644
index 00000000..49fb79f2
--- /dev/null
+++ b/scripts/external_libs/platform/fedora18/zmq/tests/test_stopwatch.py
@@ -0,0 +1,42 @@
+# -*- coding: utf8 -*-
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+
+import sys
+import time
+
+from unittest import TestCase
+
+from zmq import Stopwatch, ZMQError
+
+if sys.version_info[0] >= 3:
+ long = int
+
+class TestStopWatch(TestCase):
+
+ def test_stop_long(self):
+ """Ensure stop returns a long int."""
+ watch = Stopwatch()
+ watch.start()
+ us = watch.stop()
+ self.assertTrue(isinstance(us, long))
+
+ def test_stop_microseconds(self):
+ """Test that stop/sleep have right units."""
+ watch = Stopwatch()
+ watch.start()
+ tic = time.time()
+ watch.sleep(1)
+ us = watch.stop()
+ toc = time.time()
+ self.assertAlmostEqual(us/1e6,(toc-tic),places=0)
+
+ def test_double_stop(self):
+ """Test error raised on multiple calls to stop."""
+ watch = Stopwatch()
+ watch.start()
+ watch.stop()
+ self.assertRaises(ZMQError, watch.stop)
+ self.assertRaises(ZMQError, watch.stop)
+