-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_features_timing.py
More file actions
54 lines (43 loc) · 1.63 KB
/
test_features_timing.py
File metadata and controls
54 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# -*- coding: UTF-8 -*-
"""Timing module assets' tests.
"""
import time
from tinyscript.features.timing import set_time_items
from utils import *
args.stats = True
args.timings = True
set_time_items(globals())
class TestTiming(TestCase):
def test_step_setup(self):
g = globals().keys()
self.assertTrue(args.stats)
self.assertTrue(args.timings)
self.assertIn("get_time", g)
self.assertIn("get_time_since_last", g)
self.assertIn("Timer", g)
def test_time_manager(self):
with Timer() as t:
pass
self.assertFalse(time_manager.stats())
def test_timer_object(self):
if WINDOWS:
logger.warning("Timeout-related features are not implemented for Windows")
else:
temp_stdout(self)
with self.assertRaises(TimeoutError):
with Timer(timeout=1, fail_on_timeout=True) as timer:
self.assertTrue(timer.fail)
self.assertTrue(timer.descr)
self.assertTrue(timer.message)
self.assertTrue(timer.start)
self.assertEqual(timer.timeout, 1)
self.assertRaises(TimeoutError, timer._handler, None, None)
time.sleep(2)
with Timer(timeout=1):
time.sleep(2)
def test_timing_functions(self):
temp_stdout(self)
self.assertFalse(get_time())
self.assertFalse(get_time("test"))
self.assertFalse(get_time_since_last())
self.assertFalse(get_time_since_last("test"))