def test_stop_in_the_middle(self): ''' test_generator_actors.test_stop_in_the_middle ''' test_name = 'test_generator_actors.test_stop_in_the_middle' logger = file_logger(test_name, filename='logs/%s.log' % test_name) actor = TestActor() actor.start() self.assertEqual(actor.processing, True) for _ in range(5): actor.run_once() actor.stop() result = [] while True: try: result.append(actor.inbox.get()) except EmptyInboxException: break self.assertGreater(len(result), 1) self.assertEqual(actor.run_once(), False) self.assertEqual(actor.processing, False) self.assertEqual(actor.waiting, False)
def test_run(self): ''' test_generator_actors.test_run ''' test_name = 'test_generator_actors.test_run' logger = file_logger(test_name, filename='logs/%s.log' % test_name) actor = TestActor() actor.start() self.assertEqual(actor.processing, True) actor.run() result = [] while True: try: result.append(actor.inbox.get()) except EmptyInboxException: break self.assertEqual(len(result), 10) self.assertEqual(actor.run_once(), False) self.assertEqual(actor.processing, False) self.assertEqual(actor.waiting, False)