Exemple #1
0
 def test_timer(self):
     x = Timer()
     x.ensure_started()
     x.schedule = Mock()
     x.start()
     x.stop()
     x.schedule.clear.assert_called_with()
Exemple #2
0
 def test_timer(self):
     with mock_module(*gevent_modules):
         x = Timer()
         x.ensure_started()
         x.schedule = Mock()
         x.start()
         x.stop()
         x.schedule.clear.assert_called_with()
Exemple #3
0
    def test_sched(self):
        self.greenlet.Greenlet = object
        x = Timer()
        self.greenlet.Greenlet = Mock()
        x._Greenlet.spawn_later = Mock()
        x._GreenletExit = KeyError
        entry = Mock()
        g = x._enter(1, 0, entry)
        assert x.queue

        x._entry_exit(g)
        g.kill.assert_called_with()
        assert not x._queue

        x._queue.add(g)
        x.clear()
        x._queue.add(g)
        g.kill.side_effect = KeyError()
        x.clear()

        g = x._Greenlet()
        g.cancel()