'Errors during serialization ought to be relayed to the sender\'s
unhandledError method.'

def test_unhandledSerializationError(self):

    err = RuntimeError('something    undefined    went    wrong')
    def thunk(result):
        class BrokenBox(amp.Box, ):
            def _sendTo(self, proto):
                raise err
        return BrokenBox()
    self.locator.commands['hello'] = thunk
    input = amp.Box(_command='hello', _ask='test-command-id', hello='world')
    self.sender.expectError()
    self.dispatcher.ampBoxReceived(input)
    self.assertEqual(len(self.sender.unhandledErrors), 1)
    self.assertEqual(self.sender.unhandledErrors[0].value, err)
