Better error reporting in assertAction.

This commit is contained in:
Jeremy Fincher 2004-08-11 06:13:11 +00:00
parent ab29dbb479
commit 77ce14f481

View File

@ -299,9 +299,10 @@ class PluginTestCase(SupyTestCase):
m = self._feedMsg(query, **kwargs) m = self._feedMsg(query, **kwargs)
if m is None: if m is None:
raise TimeoutError, query raise TimeoutError, query
self.failUnless(ircmsgs.isAction(m)) self.failUnless(ircmsgs.isAction(m), '%r is not an action.' % m)
if expectedResponse is not None: if expectedResponse is not None:
self.assertEqual(ircmsgs.unAction(m), expectedResponse) s = ircmsgs.unAction(m)
self.assertEqual(s, expectedResponse, '%r != %r' % (s, m))
return m return m
def assertSnarfAction(self, query, expectedResponse=None, **kwargs): def assertSnarfAction(self, query, expectedResponse=None, **kwargs):
@ -354,10 +355,13 @@ class ChannelPluginTestCase(PluginTestCase):
self.failIf(m is None, 'No message back from joining channel.') self.failIf(m is None, 'No message back from joining channel.')
self.assertEqual(m.command, 'WHO') self.assertEqual(m.command, 'WHO')
def _feedMsg(self, query, timeout=None, to=None, frm=None, def _feedMsg(self, query, timeout=None, to=None, frm=None, private=False,
usePrefixChar=True): usePrefixChar=True):
if to is None: if to is None:
to = self.channel if private:
to = self.irc.nick
else:
to = self.channel
if frm is None: if frm is None:
frm = self.prefix frm = self.prefix
if timeout is None: if timeout is None:
@ -395,10 +399,13 @@ class ChannelPluginTestCase(PluginTestCase):
print 'Returning: %r' % ret print 'Returning: %r' % ret
return ret return ret
def feedMsg(self, query, to=None, frm=None): def feedMsg(self, query, to=None, frm=None, private=False):
"""Just feeds it a message, that's all.""" """Just feeds it a message, that's all."""
if to is None: if to is None:
to = self.channel if private:
to = self.irc.nick
else:
to = self.channel
if frm is None: if frm is None:
frm = self.prefix frm = self.prefix
self.irc.feedMsg(ircmsgs.privmsg(to, query, prefix=frm)) self.irc.feedMsg(ircmsgs.privmsg(to, query, prefix=frm))