def test_basic_events(self): events_tester = test_utils.ProcessListenerTester( process=self.proc, expected_events=('running', 'output_emitted', 'finished')) yield self.proc.step_until_terminated() self.assertSetEqual(events_tester.called, events_tester.expected_events)
def test_paused(self): events_tester = test_utils.ProcessListenerTester( self.proc, ('paused', )) self.assertTrue(self.proc.pause()) # Do the checks self.assertSetEqual(events_tester.called, events_tester.expected_events)
def test_paused(self): events_tester = test_utils.ProcessListenerTester( self.proc, ('paused', ), self.loop.stop) self.proc.pause() utils.run_loop_with_timeout(self.loop) # Do the checks self.assertSetEqual(events_tester.called, events_tester.expected_events)
def test_basic_events(self): events_tester = test_utils.ProcessListenerTester( process=self.proc, expected_events=('running', 'output_emitted', 'finished'), done_callback=self.loop.stop) self.loop.add_callback(self.proc.step_until_terminated) utils.run_loop_with_timeout(self.loop) self.assertSetEqual(events_tester.called, events_tester.expected_events)
def test_excepted(self): proc = test_utils.ExceptionProcess() events_tester = test_utils.ProcessListenerTester( proc, ( 'excepted', 'running', 'output_emitted', ), self.loop.stop) with self.assertRaises(RuntimeError): proc.execute() # Do the checks self.assertIsNotNone(proc.exception()) self.assertSetEqual(events_tester.called, events_tester.expected_events)
def test_excepted(self): proc = test_utils.ExceptionProcess() events_tester = test_utils.ProcessListenerTester( proc, ( 'excepted', 'running', 'output_emitted', )) with self.assertRaises(RuntimeError): yield proc.step_until_terminated() proc.result() # Do the checks self.assertIsNotNone(proc.exception()) self.assertSetEqual(events_tester.called, events_tester.expected_events)