Beispiel #1
0
 def test_timer(self):
     """Testing Timer: basic behaviour"""
     d = {}
     x = Timer(0.1, _testing_fn, "test", d)
     x.run()
     time.sleep(0.5)
     assert d["value"] == "test"
     x.stop()
Beispiel #2
0
 def test_timer_sleep(self):
     """Testing Timer: internal sleep"""
     with self.assertRaises(ValueError):
         x = Timer(0.1, lambda: None)
         x.fun = _stop(x)
         x.running = True
         x._run()
         x.stop()
         time.sleep = _fail
         Timer.wait(-1, seconds=0.1)
Beispiel #3
0
 def test_timer_sleep(self):
     """Testing Timer: internal sleep"""
     with self.assertRaises(ValueError):
         x = Timer(0.1, lambda: None)
         x.fun = _stop(x)
         x.running = True
         x._run()
         x.stop()
         time.sleep = _fail
         Timer.wait(-1, seconds=0.1)
Beispiel #4
0
 def test_timer(self):
     """Testing Timer: basic behaviour"""
     d = {}
     x = Timer(0.1, _testing_fn, "test", d)
     x.run()
     time.sleep(0.5)
     assert d["value"] == "test"
     x.stop()
Beispiel #5
0
 def test_timer_except(self):
     """Testing Timer: internal run"""
     with self.assertRaises(ValueError):
         x = Timer(0.1, _testing_fn_raise)
         x.running = True
         x._run()
Beispiel #6
0
 def test_not_running(self):
     """Testing Timer: not running thread"""
     x = Timer(0.1, lambda: None)
     x.running = True
     x.stop()
     x._run()
Beispiel #7
0
 def test_timer_stop(self):
     """Testing Timer: stop"""
     x = Timer(0.2, lambda: None)
     x.run()
     x.stop()
     x.wait(2, 0)  # increase to count green thread
Beispiel #8
0
 def test_timer_except(self):
     """Testing Timer: internal run"""
     with self.assertRaises(ValueError):
         x = Timer(0.1, _testing_fn_raise)
         x.running = True
         x._run()
Beispiel #9
0
 def test_not_running(self):
     """Testing Timer: not running thread"""
     x = Timer(0.1, lambda: None)
     x.running = True
     x.stop()
     x._run()
Beispiel #10
0
 def test_timer_stop(self):
     """Testing Timer: stop"""
     x = Timer(0.2, lambda: None)
     x.run()
     x.stop()
     x.wait(2, 0)  # increase to count green thread