mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-08 19:22:33 +01:00
Add test case for scheduler.addPeriodicEvent.
This commit is contained in:
parent
63a082ff34
commit
61e5edefd3
@ -73,6 +73,29 @@ class TestSchedule(SupyTestCase):
|
||||
sched.run()
|
||||
self.assertEqual(i[0], 1)
|
||||
|
||||
def testPeriodic(self):
|
||||
sched = schedule.Schedule()
|
||||
i = [0]
|
||||
def inc():
|
||||
i[0] += 1
|
||||
n = sched.addPeriodicEvent(inc, 1, name='test_periodic')
|
||||
time.sleep(0.6)
|
||||
sched.run() # 0.6
|
||||
self.assertEqual(i[0], 1)
|
||||
time.sleep(0.6)
|
||||
sched.run() # 1.2
|
||||
self.assertEqual(i[0], 2)
|
||||
time.sleep(0.6)
|
||||
sched.run() # 1.8
|
||||
self.assertEqual(i[0], 2)
|
||||
time.sleep(0.6)
|
||||
sched.run() # 2.4
|
||||
self.assertEqual(i[0], 3)
|
||||
sched.removePeriodicEvent(n)
|
||||
time.sleep(1)
|
||||
sched.run() # 3.4
|
||||
self.assertEqual(i[0], 3)
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user