Ejemplo n.º 1
0
 def test_run_no_interval(self):
     instant_function = MagicMock()
     f = RepeatingFunc('test', instant_function, 0)
     f.start()
     time.sleep(0.01)
     f.stop()
     f.join()
     assert instant_function.call_count > 10
Ejemplo n.º 2
0
    def test_run_too_slow(self):
        self.count = 0

        def slow_function():
            self.count += 1
            time.sleep(0.1)

        f = RepeatingFunc('test', slow_function, 0.01)
        f.start()
        time.sleep(0.2)
        f.stop()
        f.join()

        assert self.count > 1
        assert self.count < 3
Ejemplo n.º 3
0
 def run_loop(self, instant_function):
     f = RepeatingFunc('test', instant_function, 0.01)
     f.start()
     time.sleep(0.2)
     f.stop()
     f.join()