-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_timer.py
More file actions
32 lines (23 loc) · 679 Bytes
/
test_timer.py
File metadata and controls
32 lines (23 loc) · 679 Bytes
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
import time
from unittest import TestCase
try:
from unittest import mock
except Exception:
import mock
from stackify.timer import RepeatedTimer
class TimerTest(TestCase):
def setUp(self):
self.function_mock = mock.Mock()
self.timer = RepeatedTimer(0.1, self.function_mock)
self.timer.start()
def shutDown(self):
self.timer.stop()
def test_start(self):
assert self.timer._started
def test_stop(self):
self.timer.stop()
assert not self.timer._started
def test_timer(self):
time.sleep(0.3)
assert self.function_mock.called
assert self.function_mock.call_count >= 2