def test_errors_in_pre_start_are_reported(defer): class MyActor(Actor): def pre_start(self): raise MockException() node = DummyNode() defer(node.stop) with expect_failure(MockException): node.spawn(MyActor)
def test_errors_in_process_while_processing_a_message_are_reported(defer): class MyProc(Actor): def run(self): self.get() raise MockException node = DummyNode() defer(node.stop) p = node.spawn(MyProc) with expect_failure(MockException): p << 'dummy'
def test_errors_while_stopping_are_reported(defer): class MyProc(Actor): def run(self): try: self.get() finally: raise MockException node = DummyNode() defer(node.stop) a = node.spawn(MyProc) sleep(.001) with expect_failure(MockException): a.stop()
def test_unhandled_termination_message_causes_receiver_to_raise_unhandledtermination(defer): class Watcher(Actor): def pre_start(self): self.watch(watchee) def receive(self, message): raise Unhandled node = DummyNode() defer(node.stop) watchee = node.spawn(Actor) watchee.stop() with expect_failure(UnhandledTermination): node.spawn(Watcher)
def test_unhandled_termination_message_causes_receiver_to_raise_unhandledtermination( defer): class Watcher(Actor): def pre_start(self): self.watch(watchee) def receive(self, message): raise Unhandled node = DummyNode() defer(node.stop) watchee = node.spawn(Actor) watchee.stop() with expect_failure(UnhandledTermination): node.spawn(Watcher)
def test_error_in_stopping_proc_is_reported_nevertheless(defer): class MyProc(Actor): def run(self): self.get() released.wait() raise MockException released = Event() node = node = DummyNode() defer(node.stop) a = node.spawn(MyProc) a << 'dummy' sleep(.001) a.stop() with expect_failure(MockException): released.set()
def test_error_in_post_stop_reports_error_and_termination_messages_are_sent_as_normal(defer): class Child(Actor): def post_stop(self): raise MockException class Parent(Actor): def pre_start(self): self.child = self.spawn(Child) self.watch(self.child) self.child.stop() def receive(self, message): eq_(message, ('terminated', self.child)) termination_message_received.set() node = DummyNode() defer(node.stop) termination_message_received = Event() with expect_failure(MockException): node.spawn(Parent) termination_message_received.wait()
def test_error_in_post_stop_reports_error_and_termination_messages_are_sent_as_normal( defer): class Child(Actor): def post_stop(self): raise MockException class Parent(Actor): def pre_start(self): self.child = self.spawn(Child) self.watch(self.child) self.child.stop() def receive(self, message): eq_(message, ('terminated', self.child)) termination_message_received.set() node = DummyNode() defer(node.stop) termination_message_received = Event() with expect_failure(MockException): node.spawn(Parent) termination_message_received.wait()