Exemple #1
0
 def test_push_and_wait(self):
     code = 2
     args = ('a', 2, -1.5)
     cq = haplib.CommandQueue()
     gadz = Gadget()
     cq.register(code, gadz)
     cq.push(code, args)
     # This is not smart.
     #The processing won't be completed within 'duration'
     duration = 0.1
     cq.wait(duration)
     self.assertEquals((args, None, None, None), gadz.args)
Exemple #2
0
 def test_pop_all(self):
     code = 3
     num_push = 5
     args = ('a', 2, -1.5)
     cq = haplib.CommandQueue()
     gadz = Gadget()
     cq.register(code, gadz)
     self.assertEquals(0, gadz.num_called)
     [cq.push(code, args) for i in range(0, num_push)]
     # Too ugly. But we don't have other way to wait for completion of
     # processing in the background thread.
     while cq.__q.empty():
         time.sleep(0.01)
     cq.pop_all()
     self.assertEquals(num_push, gadz.num_called)