def send(self, msg):
    if self._closed:
        raise Exception('Mock engine send called after cleanup.')
    expected = self.expected[self.event]
    if (expected[0] == 'raise'):
        self.event += 1
        raise expected[1]
    if (expected[0] != 's'):
        raise Exception(('Mock engine send called when expecting, %s' % (expected,)))
    if (msg.rstrip() != expected[1]):
        raise Exception(('Mock engine send called with unexpected message (%s) expected (%s).' % (msg, expected[1])))
    self.event += 1
def send(self, msg):
    if self._closed:
        raise Exception('Mock engine send called after cleanup.')
    expected = self.expected[self.event]
    if (expected[0] == 'raise'):
        self.event += 1
        raise expected[1]
    if (expected[0] != 's'):
        raise Exception(('Mock engine send called when expecting, %s' % (expected,)))
    if (msg.rstrip() != expected[1]):
        raise Exception(('Mock engine send called with unexpected message (%s) expected (%s).' % (msg, expected[1])))
    self.event += 1