Esempio n. 1
0
 def testFires(self):
     interval = 0.02
     t = self._startTimer(interval)
     time.sleep(interval * 1.1)
     for i in range(10):
         if not t.isAlive():
             break
         time.sleep(interval * 0.2)
     self.assertFalse(t.isAlive())
     testhelpers.assertBetween(self, interval * 0.1, self.timediff, interval * 4)
Esempio n. 2
0
 def testResetWorks(self):
     interval = 0.02
     halfinterval = interval / 2
     t = self._startTimer(interval)
     time.sleep(halfinterval)
     t.restart()
     self.assertTrue(t.isAlive())
     threadutils.join_timeout(t)
     # A compare doesn't work- timing issues make it unreliable.
     # Just ensure we have a time diff within some acceptable threshold.
     testhelpers.assertBetween(self, interval, self.timediff, interval * 4)
Esempio n. 3
0
 def testTrue(self):
     th.assertBetween(self, 1, 2, 3)
     th.assertBetween(self, 1, 1, 3, True)
     th.assertBetween(self, 1, 3, 3, True)