'Assert that messages sent by L{IRCClient.msg} are split into an
expected number of commands and the original message is transmitted in
its entirety over those commands.'

def assertLongMessageSplitting(self, message, expectedNumCommands, length=None):

    responsePrefix = (':%s!%s@%s    ' % (self.client.nickname, self.client.realname, self.client.hostname))
    self.client.msg('foo', message, length=length)
    privmsg = []
    self.patch(self.client, 'privmsg', (lambda *a: privmsg.append(a)))
    for line in self.client.lines:
        self.client.lineReceived((responsePrefix + line))
    self.assertEqual(len(privmsg), expectedNumCommands)
    receivedMessage = ''.join((message for (user, target, message) in privmsg))
    self.assertEqual(message, receivedMessage)
