def test_1_sec_callback(self):
     rt = PeriodicTimer()
     rt.interval = 1
     rt.action(self.callback, ())
     rt.start()
     time.sleep(3)
     rt.stop()
     self.assertEqual(self.called, True, "Callback was not called")
Ejemplo n.º 2
0
 def test_2_sec_repeated(self):
     rt = PeriodicTimer()
     rt.interval = 2
     rt.action(self.callback, ())
     rt.start()
     time.sleep(3)
     self.assertEqual(self.called, True, "Callback was not called 1st time")
     self.called = False
     time.sleep(3)
     self.assertEqual(self.called, True, "Callback was not called 2nd time")