mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Replace failUnless/failIf with assertTrue/assertFalse.
The old names are deprecated.
This commit is contained in:
parent
5efd2afa27
commit
9891b0fca4
@ -110,7 +110,7 @@ class AliasTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('foobar', 'sbbone')
|
||||
self.assertRaises(Alias.AliasError, cb.removeAlias, 'foobar')
|
||||
cb.removeAlias('foobar', evenIfLocked=True)
|
||||
self.failIf('foobar' in cb.aliases)
|
||||
self.assertFalse('foobar' in cb.aliases)
|
||||
self.assertError('foobar')
|
||||
|
||||
self.assertRegexp('alias add abc\x07 ignore', 'Error.*Invalid')
|
||||
@ -167,14 +167,14 @@ class EscapedAliasTestCase(ChannelPluginTestCase):
|
||||
def testWriteDatabase(self):
|
||||
self.assertNotError('alias add fooo.spam echo egg')
|
||||
self.assertResponse('fooo.spam', 'egg')
|
||||
self.failUnless(hasattr(conf.supybot.plugins.Alias.escapedaliases,
|
||||
self.assertTrue(hasattr(conf.supybot.plugins.Alias.escapedaliases,
|
||||
'a1a4dfooospam'))
|
||||
self.assertEqual(conf.supybot.plugins.Alias.escapedaliases.a1a4dfooospam(),
|
||||
'echo egg')
|
||||
|
||||
self.assertNotError('alias add foo.spam.egg echo supybot')
|
||||
self.assertResponse('foo.spam.egg', 'supybot')
|
||||
self.failUnless(hasattr(conf.supybot.plugins.Alias.escapedaliases,
|
||||
self.assertTrue(hasattr(conf.supybot.plugins.Alias.escapedaliases,
|
||||
'a2a3d8dfoospamegg'))
|
||||
self.assertEqual(conf.supybot.plugins.Alias.escapedaliases.a2a3d8dfoospamegg(),
|
||||
'echo supybot')
|
||||
|
@ -38,7 +38,7 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(False)
|
||||
m = self.assertNotError('anonymous say %s foo!' % self.channel)
|
||||
self.failUnless(m.args[1] == 'foo!')
|
||||
self.assertTrue(m.args[1] == 'foo!')
|
||||
finally:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(origreg)
|
||||
|
||||
@ -51,7 +51,7 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
||||
self.assertError('anonymous tell %s foo!' % self.channel)
|
||||
conf.supybot.plugins.Anonymous.allowPrivateTarget.setValue(True)
|
||||
m = self.assertNotError('anonymous tell %s foo!' % self.nick)
|
||||
self.failUnless(m.args[1] == 'foo!')
|
||||
self.assertTrue(m.args[1] == 'foo!')
|
||||
finally:
|
||||
conf.supybot.plugins.Anonymous.requireRegistration.setValue(origreg)
|
||||
conf.supybot.plugins.Anonymous.allowPrivateTarget.setValue(origpriv)
|
||||
|
@ -116,18 +116,18 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('op')
|
||||
m = self.getMsg('op foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+o', 'foo'))
|
||||
m = self.getMsg('op foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+o', 'foo'))
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+o', 'bar'))
|
||||
self.irc.state.supported['MODES'] = 2
|
||||
m = self.getMsg('op foo bar')
|
||||
try:
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+oo', 'foo', 'bar'))
|
||||
finally:
|
||||
self.irc.state.supported['MODES'] = 1
|
||||
@ -137,13 +137,13 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('halfop')
|
||||
m = self.getMsg('halfop foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+h', 'foo'))
|
||||
m = self.getMsg('halfop foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+h', 'foo'))
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+h', 'bar'))
|
||||
|
||||
def testVoice(self):
|
||||
@ -151,13 +151,13 @@ class ChannelTestCase(ChannelPluginTestCase):
|
||||
self.irc.feedMsg(ircmsgs.op(self.channel, self.nick))
|
||||
self.assertNotError('voice')
|
||||
m = self.getMsg('voice foo')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+v', 'foo'))
|
||||
m = self.getMsg('voice foo bar')
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+v', 'foo'))
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'MODE' and
|
||||
self.assertTrue(m.command == 'MODE' and
|
||||
m.args == (self.channel, '+v', 'bar'))
|
||||
|
||||
def assertKban(self, query, hostmask, **kwargs):
|
||||
|
@ -155,7 +155,7 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.plugins.Factoids. \
|
||||
showFactoidIfOnlyOneMatch.setValue(False)
|
||||
m2 = self.assertNotError('factoids search m/foo/')
|
||||
self.failUnless(m1.args[1].startswith(m2.args[1]))
|
||||
self.assertTrue(m1.args[1].startswith(m2.args[1]))
|
||||
finally:
|
||||
conf.supybot.plugins.Factoids. \
|
||||
showFactoidIfOnlyOneMatch.setValue(orig)
|
||||
|
@ -156,7 +156,7 @@ class FilterTest(ChannelPluginTestCase):
|
||||
self.assertNotError('outfilter rot13')
|
||||
self.assertResponse('rot13 foobar', '%s: foobar' % s)
|
||||
m = self.getMsg('action foobar')
|
||||
self.failUnless(ircmsgs.isAction(m))
|
||||
self.assertTrue(ircmsgs.isAction(m))
|
||||
s = ircmsgs.unAction(m)
|
||||
self.assertEqual(s, 'sbbone')
|
||||
|
||||
|
@ -38,15 +38,15 @@ class GamesTestCase(ChannelPluginTestCase):
|
||||
for i in range(100):
|
||||
m = self.getMsg('roulette', frm='someoneElse!foo@bar')
|
||||
if m.command == 'PRIVMSG':
|
||||
self.failUnless(self._nonKickRe.search(m.args[1]),
|
||||
self.assertTrue(self._nonKickRe.search(m.args[1]),
|
||||
'Got a msg without bang|click|spin: %r' % m)
|
||||
elif m.command == 'KICK':
|
||||
sawKick = True
|
||||
self.failUnless('bang' in m.args[2].lower(),
|
||||
self.assertTrue('bang' in m.args[2].lower(),
|
||||
'Got a KICK without bang in it.')
|
||||
else:
|
||||
self.fail('Got something other than a kick or a privmsg.')
|
||||
self.failUnless(sawKick, 'Didn\'t get a kick in %s iterations!' % i)
|
||||
self.assertTrue(sawKick, 'Didn\'t get a kick in %s iterations!' % i)
|
||||
|
||||
def testEightball(self):
|
||||
self.assertNotError('eightball')
|
||||
|
@ -43,7 +43,7 @@ class LimiterTestCase(ChannelPluginTestCase):
|
||||
self.assertEqual(m, ircmsgs.limit('#foo', 1+10))
|
||||
self.irc.feedMsg(ircmsgs.join('#foo', prefix='bar!root@host'))
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is not None)
|
||||
self.assertFalse(m is not None)
|
||||
conf.supybot.plugins.Limiter.maximumExcess.setValue(7)
|
||||
self.irc.feedMsg(ircmsgs.part('#foo', prefix='bar!root@host'))
|
||||
m = self.irc.takeMsg()
|
||||
|
@ -105,23 +105,23 @@ class MessageParserTestCase(ChannelPluginTestCase):
|
||||
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||
self.feedMsg('this message has some stuff in it')
|
||||
m = self.getMsg(' ')
|
||||
self.failUnless(str(m).startswith('PRIVMSG #test :i saw some stuff'))
|
||||
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some stuff'))
|
||||
|
||||
def testMaxTriggers(self):
|
||||
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||
self.assertNotError('messageparser add "sbd" "echo i saw somebody"')
|
||||
self.feedMsg('this message issued by sbd has some stuff in it')
|
||||
m = self.getMsg(' ')
|
||||
self.failUnless(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
m = self.getMsg(' ')
|
||||
self.failUnless(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
|
||||
with conf.supybot.plugins.messageparser.maxtriggers.context(1):
|
||||
self.feedMsg('this message issued by sbd has some stuff in it')
|
||||
m = self.getMsg(' ')
|
||||
self.failUnless(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
self.assertTrue(str(m).startswith('PRIVMSG #test :i saw some'))
|
||||
m = self.getMsg(' ')
|
||||
self.failIf(m)
|
||||
self.assertFalse(m)
|
||||
|
||||
def testLock(self):
|
||||
self.assertNotError('messageparser add "stuff" "echo i saw some stuff"')
|
||||
|
@ -86,11 +86,11 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
def testHelpIncludeFullCommandName(self):
|
||||
self.assertHelp('help channel capability add')
|
||||
m = self.getMsg('help channel capability add')
|
||||
self.failUnless('channel capability add' in m.args[1])
|
||||
self.assertTrue('channel capability add' in m.args[1])
|
||||
|
||||
def testHelpDoesAmbiguityWithDefaultPlugins(self):
|
||||
m = self.getMsg('help list') # Misc.list and User.list.
|
||||
self.failIf(m.args[1].startswith('Error'))
|
||||
self.assertFalse(m.args[1].startswith('Error'))
|
||||
|
||||
def testHelpIsCaseInsensitive(self):
|
||||
self.assertHelp('help LIST')
|
||||
@ -145,19 +145,19 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
oldprefix, self.prefix = self.prefix, 'tester!foo@bar__no_testcap__baz'
|
||||
self.nick = 'tester'
|
||||
m = self.getMsg('tell aljsdkfh [plugin tell]')
|
||||
self.failUnless('let you do' in m.args[1])
|
||||
self.assertTrue('let you do' in m.args[1])
|
||||
m = self.getMsg('tell #foo [plugin tell]')
|
||||
self.failUnless('No need for' in m.args[1])
|
||||
self.assertTrue('No need for' in m.args[1])
|
||||
m = self.getMsg('tell me you love me')
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.args[0] == self.nick)
|
||||
self.assertTrue(m.args[0] == self.nick)
|
||||
|
||||
def testNoNestedTell(self):
|
||||
self.assertRegexp('echo [tell %s foo]' % self.nick, 'nested')
|
||||
|
||||
def testTellDoesNotPropogateAction(self):
|
||||
m = self.getMsg('tell foo [action bar]')
|
||||
self.failIf(ircmsgs.isAction(m))
|
||||
self.assertFalse(ircmsgs.isAction(m))
|
||||
|
||||
def testLast(self):
|
||||
orig = conf.supybot.plugins.Misc.timestampFormat()
|
||||
|
@ -53,11 +53,11 @@ class OptionListTestCase(SupyTestCase):
|
||||
while max and L:
|
||||
max -= 1
|
||||
option = plugin.pickOptions(s)
|
||||
self.failUnless(option in original,
|
||||
self.assertTrue(option in original,
|
||||
'Option %s not in %s' % (option, original))
|
||||
if option in L:
|
||||
L.remove(option)
|
||||
self.failIf(L, 'Some options never seen: %s' % L)
|
||||
self.assertFalse(L, 'Some options never seen: %s' % L)
|
||||
|
||||
def testPickOptions(self):
|
||||
self._testOptions('(a|b)', ['a', 'b'])
|
||||
@ -356,7 +356,7 @@ class FactoidsTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('foo', 'foo is bar')
|
||||
self.irc.feedMsg(ircmsgs.privmsg(self.irc.nick, '\x01VERSION\x01'))
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m)
|
||||
self.assertFalse(m)
|
||||
|
||||
def testAddFactoidNotCalledWithBadNestingSyntax(self):
|
||||
self.assertError('re s/Error:.*/foo/ ]')
|
||||
|
@ -371,7 +371,7 @@ class RSSTestCase(ChannelPluginTestCase):
|
||||
timeFastForward(1.1)
|
||||
self.assertNotError('rss %s' % url)
|
||||
m = self.assertNotError('rss %s 2' % url)
|
||||
self.failUnless(m.args[1].count(' | ') == 1)
|
||||
self.assertTrue(m.args[1].count(' | ') == 1)
|
||||
|
||||
def testRssAdd(self):
|
||||
timeFastForward(1.1)
|
||||
|
@ -34,7 +34,7 @@ class ReplyTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Reply',)
|
||||
def testPrivate(self):
|
||||
m = self.getMsg('private [list]')
|
||||
self.failIf(self.irc.isChannel(m.args[0]))
|
||||
self.assertFalse(self.irc.isChannel(m.args[0]))
|
||||
|
||||
def testNotice(self):
|
||||
m = self.getMsg('notice [list]')
|
||||
@ -62,6 +62,6 @@ class ReplyNonChannelTestCase(PluginTestCase):
|
||||
self.prefix = 'something!else@somewhere.else'
|
||||
self.nick = 'something'
|
||||
m = self.assertAction('action foo', 'foo')
|
||||
self.failIf(m.args[0] == self.irc.nick)
|
||||
self.assertFalse(m.args[0] == self.irc.nick)
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -54,7 +54,7 @@ class SchedulerTestCase(ChannelPluginTestCase):
|
||||
if s.isdigit():
|
||||
id = s
|
||||
break
|
||||
self.failUnless(id, 'Couldn\'t find id in reply.')
|
||||
self.assertTrue(id, 'Couldn\'t find id in reply.')
|
||||
self.assertNotError('scheduler remove %s' % id)
|
||||
timeFastForward(5)
|
||||
self.assertNoResponse(' ', timeout=1)
|
||||
|
@ -85,7 +85,7 @@ class ChannelDBTestCase(ChannelPluginTestCase):
|
||||
self.assertError('seen *')
|
||||
self.assertNotError('seen %s' % self.nick)
|
||||
m = self.assertNotError('seen %s' % self.nick.upper())
|
||||
self.failUnless(self.nick.upper() in m.args[1])
|
||||
self.assertTrue(self.nick.upper() in m.args[1])
|
||||
self.assertRegexp('seen user %s' % self.nick,
|
||||
'^%s was last seen' % self.nick)
|
||||
self.assertNotError('config plugins.Seen.minimumNonWildcard 0')
|
||||
|
@ -41,12 +41,12 @@ class ServicesTestCase(PluginTestCase):
|
||||
self.assertError('services identify') # Don't have a password.
|
||||
self.assertNotError('services password %s baz' % self.nick)
|
||||
m = self.assertNotError('services identify')
|
||||
self.failUnless(m.args[0] == 'NickServ')
|
||||
self.failUnless(m.args[1].lower() == 'identify baz')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify baz')
|
||||
self.assertNotError('services password %s biff' % self.nick)
|
||||
m = self.assertNotError('services identify')
|
||||
self.failUnless(m.args[0] == 'NickServ')
|
||||
self.failUnless(m.args[1].lower() == 'identify biff')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify biff')
|
||||
|
||||
def testPasswordConfg(self):
|
||||
self.assertNotError('config plugins.Services.nicks ""')
|
||||
@ -72,8 +72,8 @@ class ServicesTestCase(PluginTestCase):
|
||||
'Global: bar; test: bar2')
|
||||
|
||||
m = self.assertNotError('services identify')
|
||||
self.failUnless(m.args[0] == 'NickServ')
|
||||
self.failUnless(m.args[1].lower() == 'identify bar2')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify bar2')
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -40,11 +40,11 @@ class StatusTestCase(PluginTestCase):
|
||||
|
||||
def testCpu(self):
|
||||
m = self.assertNotError('status cpu')
|
||||
self.failIf('kB kB' in m.args[1])
|
||||
self.failIf('None' in m.args[1], 'None in cpu output: %r.' % m)
|
||||
self.assertFalse('kB kB' in m.args[1])
|
||||
self.assertFalse('None' in m.args[1], 'None in cpu output: %r.' % m)
|
||||
for s in ['linux', 'freebsd', 'openbsd', 'netbsd', 'darwin']:
|
||||
if sys.platform.startswith(s):
|
||||
self.failUnless('B' in m.args[1] or 'KB' in m.args[1] or
|
||||
self.assertTrue('B' in m.args[1] or 'KB' in m.args[1] or
|
||||
'MB' in m.args[1],
|
||||
'No memory string on supported platform.')
|
||||
try:
|
||||
|
@ -128,7 +128,7 @@ class TopicTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.plugins.Topic.separator.setValue(' <==> ')
|
||||
_ = self.getMsg('topic add foo')
|
||||
m = self.getMsg('topic add bar')
|
||||
self.failUnless('<==>' in m.args[1])
|
||||
self.assertTrue('<==>' in m.args[1])
|
||||
finally:
|
||||
conf.supybot.plugins.Topic.separator.setValue(original)
|
||||
|
||||
|
@ -103,13 +103,13 @@ class UserTestCase(PluginTestCase):
|
||||
self.assertResponse('hostmask', self.prefix)
|
||||
self.assertError('@hostmask asdf')
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is not None, m)
|
||||
self.assertFalse(m is not None, m)
|
||||
|
||||
def testRegisterUnregister(self):
|
||||
self.prefix = self.prefix1
|
||||
self.assertNotError('register foo bar')
|
||||
self.assertError('register foo baz')
|
||||
self.failUnless(ircdb.users.getUserId('foo'))
|
||||
self.assertTrue(ircdb.users.getUserId('foo'))
|
||||
self.assertError('unregister foo')
|
||||
self.assertNotError('unregister foo bar')
|
||||
self.assertRaises(KeyError, ircdb.users.getUserId, 'foo')
|
||||
@ -122,8 +122,8 @@ class UserTestCase(PluginTestCase):
|
||||
try:
|
||||
self.assertError('unregister foo')
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is not None, m)
|
||||
self.failUnless(ircdb.users.getUserId('foo'))
|
||||
self.assertFalse(m is not None, m)
|
||||
self.assertTrue(ircdb.users.getUserId('foo'))
|
||||
finally:
|
||||
conf.supybot.databases.users.allowUnregistration.setValue(orig)
|
||||
|
||||
|
@ -41,7 +41,7 @@ class WebTestCase(ChannelPluginTestCase):
|
||||
self.assertError('doctype ftp://ftp.cdrom.com/pub/linux')
|
||||
self.assertNotError('doctype http://www.slashdot.org/')
|
||||
m = self.getMsg('doctype http://moobot.sf.net/')
|
||||
self.failUnless(m.args[1].endswith('>'))
|
||||
self.assertTrue(m.args[1].endswith('>'))
|
||||
|
||||
def testSize(self):
|
||||
self.assertError('size ftp://ftp.cdrom.com/pub/linux')
|
||||
|
30
src/test.py
30
src/test.py
@ -342,7 +342,7 @@ class PluginTestCase(SupyTestCase):
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
if lastGetHelp not in m.args[1]:
|
||||
self.failUnless(m.args[1].startswith('Error:'),
|
||||
self.assertTrue(m.args[1].startswith('Error:'),
|
||||
'%r did not error: %s' % (query, m.args[1]))
|
||||
return m
|
||||
|
||||
@ -353,9 +353,9 @@ class PluginTestCase(SupyTestCase):
|
||||
m = self._feedMsg(query, **kwargs)
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
self.failIf(m.args[1].startswith('Error:'),
|
||||
self.assertFalse(m.args[1].startswith('Error:'),
|
||||
'%r errored: %s' % (query, m.args[1]))
|
||||
self.failIf(lastGetHelp in m.args[1],
|
||||
self.assertFalse(lastGetHelp in m.args[1],
|
||||
'%r returned the help string.' % query)
|
||||
return m
|
||||
|
||||
@ -369,13 +369,13 @@ class PluginTestCase(SupyTestCase):
|
||||
msg = m.args[1]
|
||||
if 'more message' in msg:
|
||||
msg = msg[0:-27] # Strip (XXX more messages)
|
||||
self.failUnless(msg in lastGetHelp,
|
||||
self.assertTrue(msg in lastGetHelp,
|
||||
'%s is not the help (%s)' % (m.args[1], lastGetHelp))
|
||||
return m
|
||||
|
||||
def assertNoResponse(self, query, timeout=0, **kwargs):
|
||||
m = self._feedMsg(query, timeout=timeout, **kwargs)
|
||||
self.failIf(m, 'Unexpected response: %r' % m)
|
||||
self.assertFalse(m, 'Unexpected response: %r' % m)
|
||||
return m
|
||||
|
||||
def assertSnarfNoResponse(self, query, timeout=0, **kwargs):
|
||||
@ -398,7 +398,7 @@ class PluginTestCase(SupyTestCase):
|
||||
m = self._feedMsg(query, **kwargs)
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
self.failUnless(re.search(regexp, m.args[1], flags),
|
||||
self.assertTrue(re.search(regexp, m.args[1], flags),
|
||||
'%r does not match %r' % (m.args[1], regexp))
|
||||
return m
|
||||
|
||||
@ -410,7 +410,7 @@ class PluginTestCase(SupyTestCase):
|
||||
m = self._feedMsg(query, **kwargs)
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
self.failUnless(re.search(regexp, m.args[1], flags) is None,
|
||||
self.assertTrue(re.search(regexp, m.args[1], flags) is None,
|
||||
'%r matched %r' % (m.args[1], regexp))
|
||||
return m
|
||||
|
||||
@ -422,7 +422,7 @@ class PluginTestCase(SupyTestCase):
|
||||
m = self._feedMsg(query, **kwargs)
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
self.failUnless(ircmsgs.isAction(m), '%r is not an action.' % m)
|
||||
self.assertTrue(ircmsgs.isAction(m), '%r is not an action.' % m)
|
||||
if expectedResponse is not None:
|
||||
s = ircmsgs.unAction(m)
|
||||
self.assertEqual(s, expectedResponse,
|
||||
@ -437,9 +437,9 @@ class PluginTestCase(SupyTestCase):
|
||||
m = self._feedMsg(query, **kwargs)
|
||||
if m is None:
|
||||
raise TimeoutError(query)
|
||||
self.failUnless(ircmsgs.isAction(m))
|
||||
self.assertTrue(ircmsgs.isAction(m))
|
||||
s = ircmsgs.unAction(m)
|
||||
self.failUnless(re.search(regexp, s, flags),
|
||||
self.assertTrue(re.search(regexp, s, flags),
|
||||
'%r does not match %r' % (s, regexp))
|
||||
|
||||
def assertSnarfActionRegexp(self, query, regexp, flags=re.I, **kwargs):
|
||||
@ -456,13 +456,13 @@ class PluginTestCase(SupyTestCase):
|
||||
if ((name in self._noTestDoc) and \
|
||||
not name.lower() in self.__class__.__name__.lower()):
|
||||
continue
|
||||
self.failUnless(sys.modules[cb.__class__.__name__].__doc__,
|
||||
self.assertTrue(sys.modules[cb.__class__.__name__].__doc__,
|
||||
'%s has no module documentation.' % name)
|
||||
if hasattr(cb, 'isCommandMethod'):
|
||||
for attr in dir(cb):
|
||||
if cb.isCommandMethod(attr) and \
|
||||
attr == callbacks.canonicalName(attr):
|
||||
self.failUnless(getattr(cb, attr, None).__doc__,
|
||||
self.assertTrue(getattr(cb, attr, None).__doc__,
|
||||
'%s.%s has no help.' % (name, attr))
|
||||
|
||||
|
||||
@ -476,13 +476,13 @@ class ChannelPluginTestCase(PluginTestCase):
|
||||
PluginTestCase.setUp(self)
|
||||
self.irc.feedMsg(ircmsgs.join(self.channel, prefix=self.prefix))
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is None, 'No message back from joining channel.')
|
||||
self.assertFalse(m is None, 'No message back from joining channel.')
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is None, 'No message back from joining channel.')
|
||||
self.assertFalse(m is None, 'No message back from joining channel.')
|
||||
self.assertEqual(m.command, 'MODE')
|
||||
m = self.irc.takeMsg()
|
||||
self.failIf(m is None, 'No message back from joining channel.')
|
||||
self.assertFalse(m is None, 'No message back from joining channel.')
|
||||
self.assertEqual(m.command, 'WHO')
|
||||
|
||||
def _feedMsg(self, query, timeout=None, to=None, frm=None, private=False,
|
||||
|
@ -184,9 +184,9 @@ class FunctionsTestCase(SupyTestCase):
|
||||
'%s: foo' % nick.capitalize(), '%s: foo' % nick.upper()]
|
||||
inChannel = [ircmsgs.privmsg('#foo', s) for s in inChannel]
|
||||
badmsg = ircmsgs.privmsg('#foo', '%s:foo' % nick)
|
||||
self.failIf(callbacks.addressed(nick, badmsg))
|
||||
self.assertFalse(callbacks.addressed(nick, badmsg))
|
||||
badmsg = ircmsgs.privmsg('#foo', '%s^: foo' % nick)
|
||||
self.failIf(callbacks.addressed(nick, badmsg))
|
||||
self.assertFalse(callbacks.addressed(nick, badmsg))
|
||||
for msg in inChannel:
|
||||
self.assertEqual('foo', callbacks.addressed(nick, msg), msg)
|
||||
msg = ircmsgs.privmsg(nick, 'foo')
|
||||
@ -198,7 +198,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
msg = ircmsgs.privmsg('#foo', '%s: foo' % nick.upper())
|
||||
self.assertEqual('foo', callbacks.addressed(nick, msg))
|
||||
badmsg = ircmsgs.privmsg('#foo', '%s`: foo' % nick)
|
||||
self.failIf(callbacks.addressed(nick, badmsg))
|
||||
self.assertFalse(callbacks.addressed(nick, badmsg))
|
||||
|
||||
def testAddressedReplyWhenNotAddressed(self):
|
||||
msg1 = ircmsgs.privmsg('#foo', '@bar')
|
||||
@ -382,15 +382,15 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
def testReplyWithNickPrefix(self):
|
||||
self.feedMsg('@len foo')
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m is not None, 'm: %r' % m)
|
||||
self.failUnless(m.args[1].startswith(self.nick))
|
||||
self.assertTrue(m is not None, 'm: %r' % m)
|
||||
self.assertTrue(m.args[1].startswith(self.nick))
|
||||
try:
|
||||
original = conf.supybot.reply.withNickPrefix()
|
||||
conf.supybot.reply.withNickPrefix.setValue(False)
|
||||
self.feedMsg('@len foobar')
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m is not None)
|
||||
self.failIf(m.args[1].startswith(self.nick))
|
||||
self.assertTrue(m is not None)
|
||||
self.assertFalse(m.args[1].startswith(self.nick))
|
||||
finally:
|
||||
conf.supybot.reply.withNickPrefix.setValue(original)
|
||||
|
||||
@ -399,8 +399,8 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
original = conf.supybot.reply.error.inPrivate()
|
||||
conf.supybot.reply.error.inPrivate.setValue(False)
|
||||
m = self.getMsg("eval irc.error('foo', private=True)")
|
||||
self.failUnless(m, 'No message returned.')
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
self.assertTrue(m, 'No message returned.')
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.error.inPrivate.setValue(original)
|
||||
|
||||
@ -412,8 +412,8 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
original = conf.supybot.reply.error.withNotice()
|
||||
conf.supybot.reply.error.withNotice.setValue(True)
|
||||
m = self.getMsg("eval irc.error('foo')")
|
||||
self.failUnless(m, 'No message returned.')
|
||||
self.failUnless(m.command == 'NOTICE')
|
||||
self.assertTrue(m, 'No message returned.')
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
finally:
|
||||
conf.supybot.reply.error.withNotice.setValue(original)
|
||||
|
||||
@ -428,10 +428,10 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
s = 're s/foo/bar baz' # will error; should be "re s/foo/bar/ baz"
|
||||
self.assertError(s)
|
||||
m = self.getMsg(s)
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
conf.supybot.reply.error.inPrivate.set('True')
|
||||
m = self.getMsg(s)
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.error.inPrivate.set(original)
|
||||
|
||||
@ -508,7 +508,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
self.irc.addCallback(self.TwoRepliesFirstAction(self.irc))
|
||||
self.assertAction('testactionreply', 'foo')
|
||||
m = self.getMsg(' ')
|
||||
self.failIf(m.args[1].startswith('\x01ACTION'))
|
||||
self.assertFalse(m.args[1].startswith('\x01ACTION'))
|
||||
|
||||
def testEmptyNest(self):
|
||||
try:
|
||||
@ -670,11 +670,11 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
self.irc.addCallback(self.WithPrivateNotice(self.irc))
|
||||
# Check normal behavior.
|
||||
m = self.assertNotError('normal')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
# Check abnormal behavior.
|
||||
originalInPrivate = conf.supybot.reply.inPrivate()
|
||||
originalWithNotice = conf.supybot.reply.withNotice()
|
||||
@ -682,11 +682,11 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.reply.inPrivate.setValue(True)
|
||||
conf.supybot.reply.withNotice.setValue(True)
|
||||
m = self.assertNotError('normal')
|
||||
self.failUnless(m.command == 'NOTICE')
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.inPrivate.setValue(originalInPrivate)
|
||||
conf.supybot.reply.withNotice.setValue(originalWithNotice)
|
||||
@ -694,11 +694,11 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(True)
|
||||
m = self.assertNotError('implicit')
|
||||
self.failUnless(m.command == 'NOTICE')
|
||||
self.failIf(ircutils.isChannel(m.args[0]))
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('normal')
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.failUnless(ircutils.isChannel(m.args[0]))
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(orig)
|
||||
|
||||
@ -707,10 +707,10 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(True)
|
||||
m = self.assertNotError("eval irc.reply('y',to='x',private=True)")
|
||||
self.failUnless(m.command == 'NOTICE')
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
m = self.getMsg(' ')
|
||||
m = self.assertNotError("eval irc.reply('y',to='#x',private=True)")
|
||||
self.failIf(m.command == 'NOTICE')
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
finally:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(original)
|
||||
|
||||
@ -722,28 +722,28 @@ class ProxyTestCase(SupyTestCase):
|
||||
irc = irclib.Irc('test')
|
||||
proxy = callbacks.SimpleProxy(irc, msg)
|
||||
# First one way...
|
||||
self.failIf(proxy != irc)
|
||||
self.failUnless(proxy == irc)
|
||||
self.assertFalse(proxy != irc)
|
||||
self.assertTrue(proxy == irc)
|
||||
self.assertEqual(hash(proxy), hash(irc))
|
||||
# Then the other!
|
||||
self.failIf(irc != proxy)
|
||||
self.failUnless(irc == proxy)
|
||||
self.assertFalse(irc != proxy)
|
||||
self.assertTrue(irc == proxy)
|
||||
self.assertEqual(hash(irc), hash(proxy))
|
||||
|
||||
# And now dictionaries...
|
||||
d = {}
|
||||
d[irc] = 'foo'
|
||||
self.failUnless(len(d) == 1)
|
||||
self.failUnless(d[irc] == 'foo')
|
||||
self.failUnless(d[proxy] == 'foo')
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'foo')
|
||||
self.assertTrue(d[proxy] == 'foo')
|
||||
d[proxy] = 'bar'
|
||||
self.failUnless(len(d) == 1)
|
||||
self.failUnless(d[irc] == 'bar')
|
||||
self.failUnless(d[proxy] == 'bar')
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'bar')
|
||||
self.assertTrue(d[proxy] == 'bar')
|
||||
d[irc] = 'foo'
|
||||
self.failUnless(len(d) == 1)
|
||||
self.failUnless(d[irc] == 'foo')
|
||||
self.failUnless(d[proxy] == 'foo')
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'foo')
|
||||
self.assertTrue(d[proxy] == 'foo')
|
||||
|
||||
|
||||
|
||||
|
@ -193,7 +193,7 @@ class ConverterTestCase(CommandsTestCase):
|
||||
|
||||
class FirstTestCase(CommandsTestCase):
|
||||
def testRepr(self):
|
||||
self.failUnless(repr(first('int')))
|
||||
self.assertTrue(repr(first('int')))
|
||||
|
||||
def testFirstConverterFailsAndNotErroredState(self):
|
||||
self.assertStateErrored([first('int', 'something')], ['words'],
|
||||
|
@ -31,7 +31,7 @@ from supybot.test import *
|
||||
|
||||
class FormatTestCase(SupyTestCase):
|
||||
def test_t_acceptsNone(self):
|
||||
self.failUnless(format('%t', None))
|
||||
self.assertTrue(format('%t', None))
|
||||
|
||||
def testFloatingPoint(self):
|
||||
self.assertEqual(format('%.2f', 0.12345), '0.12')
|
||||
|
@ -48,17 +48,17 @@ class IrcdbTestCase(SupyTestCase):
|
||||
|
||||
class FunctionsTestCase(IrcdbTestCase):
|
||||
def testIsAntiCapability(self):
|
||||
self.failIf(ircdb.isAntiCapability('foo'))
|
||||
self.failIf(ircdb.isAntiCapability('#foo,bar'))
|
||||
self.failUnless(ircdb.isAntiCapability('-foo'))
|
||||
self.failUnless(ircdb.isAntiCapability('#foo,-bar'))
|
||||
self.failUnless(ircdb.isAntiCapability('#foo.bar,-baz'))
|
||||
self.assertFalse(ircdb.isAntiCapability('foo'))
|
||||
self.assertFalse(ircdb.isAntiCapability('#foo,bar'))
|
||||
self.assertTrue(ircdb.isAntiCapability('-foo'))
|
||||
self.assertTrue(ircdb.isAntiCapability('#foo,-bar'))
|
||||
self.assertTrue(ircdb.isAntiCapability('#foo.bar,-baz'))
|
||||
|
||||
def testIsChannelCapability(self):
|
||||
self.failIf(ircdb.isChannelCapability('foo'))
|
||||
self.failUnless(ircdb.isChannelCapability('#foo,bar'))
|
||||
self.failUnless(ircdb.isChannelCapability('#foo.bar,baz'))
|
||||
self.failUnless(ircdb.isChannelCapability('#foo,bar.baz'))
|
||||
self.assertFalse(ircdb.isChannelCapability('foo'))
|
||||
self.assertTrue(ircdb.isChannelCapability('#foo,bar'))
|
||||
self.assertTrue(ircdb.isChannelCapability('#foo.bar,baz'))
|
||||
self.assertTrue(ircdb.isChannelCapability('#foo,bar.baz'))
|
||||
|
||||
def testMakeAntiCapability(self):
|
||||
self.assertEqual(ircdb.makeAntiCapability('foo'), '-foo')
|
||||
@ -94,17 +94,17 @@ class CapabilitySetTestCase(SupyTestCase):
|
||||
d = ircdb.CapabilitySet()
|
||||
self.assertRaises(KeyError, d.check, 'foo')
|
||||
d = ircdb.CapabilitySet(('foo',))
|
||||
self.failUnless(d.check('foo'))
|
||||
self.failIf(d.check('-foo'))
|
||||
self.assertTrue(d.check('foo'))
|
||||
self.assertFalse(d.check('-foo'))
|
||||
d.add('bar')
|
||||
self.failUnless(d.check('bar'))
|
||||
self.failIf(d.check('-bar'))
|
||||
self.assertTrue(d.check('bar'))
|
||||
self.assertFalse(d.check('-bar'))
|
||||
d.add('-baz')
|
||||
self.failIf(d.check('baz'))
|
||||
self.failUnless(d.check('-baz'))
|
||||
self.assertFalse(d.check('baz'))
|
||||
self.assertTrue(d.check('-baz'))
|
||||
d.add('-bar')
|
||||
self.failIf(d.check('bar'))
|
||||
self.failUnless(d.check('-bar'))
|
||||
self.assertFalse(d.check('bar'))
|
||||
self.assertTrue(d.check('-bar'))
|
||||
d.remove('-bar')
|
||||
self.assertRaises(KeyError, d.check, '-bar')
|
||||
self.assertRaises(KeyError, d.check, 'bar')
|
||||
@ -119,31 +119,31 @@ class CapabilitySetTestCase(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
s = ircdb.CapabilitySet()
|
||||
self.failIf('foo' in s)
|
||||
self.failIf('-foo' in s)
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('-foo' in s)
|
||||
s.add('foo')
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('-foo' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
s.remove('foo')
|
||||
self.failIf('foo' in s)
|
||||
self.failIf('-foo' in s)
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('-foo' in s)
|
||||
s.add('-foo')
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('-foo' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
|
||||
def testCheck(self):
|
||||
s = ircdb.CapabilitySet()
|
||||
self.assertRaises(KeyError, s.check, 'foo')
|
||||
self.assertRaises(KeyError, s.check, '-foo')
|
||||
s.add('foo')
|
||||
self.failUnless(s.check('foo'))
|
||||
self.failIf(s.check('-foo'))
|
||||
self.assertTrue(s.check('foo'))
|
||||
self.assertFalse(s.check('-foo'))
|
||||
s.remove('foo')
|
||||
self.assertRaises(KeyError, s.check, 'foo')
|
||||
self.assertRaises(KeyError, s.check, '-foo')
|
||||
s.add('-foo')
|
||||
self.failIf(s.check('foo'))
|
||||
self.failUnless(s.check('-foo'))
|
||||
self.assertFalse(s.check('foo'))
|
||||
self.assertTrue(s.check('-foo'))
|
||||
s.remove('-foo')
|
||||
self.assertRaises(KeyError, s.check, 'foo')
|
||||
self.assertRaises(KeyError, s.check, '-foo')
|
||||
@ -152,26 +152,26 @@ class CapabilitySetTestCase(SupyTestCase):
|
||||
s = ircdb.CapabilitySet()
|
||||
s.add('foo')
|
||||
s.add('-foo')
|
||||
self.failIf(s.check('foo'))
|
||||
self.failUnless(s.check('-foo'))
|
||||
self.assertFalse(s.check('foo'))
|
||||
self.assertTrue(s.check('-foo'))
|
||||
s.add('foo')
|
||||
self.failUnless(s.check('foo'))
|
||||
self.failIf(s.check('-foo'))
|
||||
self.assertTrue(s.check('foo'))
|
||||
self.assertFalse(s.check('-foo'))
|
||||
|
||||
|
||||
class UserCapabilitySetTestCase(SupyTestCase):
|
||||
def testOwnerHasAll(self):
|
||||
d = ircdb.UserCapabilitySet(('owner',))
|
||||
self.failIf(d.check('-foo'))
|
||||
self.failUnless(d.check('foo'))
|
||||
self.assertFalse(d.check('-foo'))
|
||||
self.assertTrue(d.check('foo'))
|
||||
|
||||
def testOwnerIsAlwaysPresent(self):
|
||||
d = ircdb.UserCapabilitySet()
|
||||
self.failUnless('owner' in d)
|
||||
self.failUnless('-owner' in d)
|
||||
self.failIf(d.check('owner'))
|
||||
self.assertTrue('owner' in d)
|
||||
self.assertTrue('-owner' in d)
|
||||
self.assertFalse(d.check('owner'))
|
||||
d.add('owner')
|
||||
self.failUnless(d.check('owner'))
|
||||
self.assertTrue(d.check('owner'))
|
||||
|
||||
def testReprEval(self):
|
||||
s = ircdb.UserCapabilitySet()
|
||||
@ -184,30 +184,30 @@ class UserCapabilitySetTestCase(SupyTestCase):
|
||||
def testOwner(self):
|
||||
s = ircdb.UserCapabilitySet()
|
||||
s.add('owner')
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('-foo' in s)
|
||||
self.failUnless(s.check('owner'))
|
||||
self.failIf(s.check('-owner'))
|
||||
self.failIf(s.check('-foo'))
|
||||
self.failUnless(s.check('foo'))
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
self.assertTrue(s.check('owner'))
|
||||
self.assertFalse(s.check('-owner'))
|
||||
self.assertFalse(s.check('-foo'))
|
||||
self.assertTrue(s.check('foo'))
|
||||
|
||||
## def testWorksAfterReload(self):
|
||||
## s = ircdb.UserCapabilitySet(['owner'])
|
||||
## self.failUnless(s.check('owner'))
|
||||
## self.assertTrue(s.check('owner'))
|
||||
## import sets
|
||||
## reload(sets)
|
||||
## self.failUnless(s.check('owner'))
|
||||
## self.assertTrue(s.check('owner'))
|
||||
|
||||
|
||||
class IrcUserTestCase(IrcdbTestCase):
|
||||
def testCapabilities(self):
|
||||
u = ircdb.IrcUser()
|
||||
u.addCapability('foo')
|
||||
self.failUnless(u._checkCapability('foo'))
|
||||
self.failIf(u._checkCapability('-foo'))
|
||||
self.assertTrue(u._checkCapability('foo'))
|
||||
self.assertFalse(u._checkCapability('-foo'))
|
||||
u.addCapability('-bar')
|
||||
self.failUnless(u._checkCapability('-bar'))
|
||||
self.failIf(u._checkCapability('bar'))
|
||||
self.assertTrue(u._checkCapability('-bar'))
|
||||
self.assertFalse(u._checkCapability('bar'))
|
||||
u.removeCapability('foo')
|
||||
u.removeCapability('-bar')
|
||||
self.assertRaises(KeyError, u._checkCapability, 'foo')
|
||||
@ -220,26 +220,26 @@ class IrcUserTestCase(IrcdbTestCase):
|
||||
def testRemoveHostmask(self):
|
||||
u = ircdb.IrcUser()
|
||||
u.addHostmask('foo!bar@baz')
|
||||
self.failUnless(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
u.addHostmask('foo!bar@baz')
|
||||
u.removeHostmask('foo!bar@baz')
|
||||
self.failIf(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertFalse(u.checkHostmask('foo!bar@baz'))
|
||||
|
||||
def testOwner(self):
|
||||
u = ircdb.IrcUser()
|
||||
u.addCapability('owner')
|
||||
self.failUnless(u._checkCapability('foo'))
|
||||
self.failIf(u._checkCapability('-foo'))
|
||||
self.assertTrue(u._checkCapability('foo'))
|
||||
self.assertFalse(u._checkCapability('-foo'))
|
||||
|
||||
def testInitCapabilities(self):
|
||||
u = ircdb.IrcUser(capabilities=['foo'])
|
||||
self.failUnless(u._checkCapability('foo'))
|
||||
self.assertTrue(u._checkCapability('foo'))
|
||||
|
||||
def testPassword(self):
|
||||
u = ircdb.IrcUser()
|
||||
u.setPassword('foobar')
|
||||
self.failUnless(u.checkPassword('foobar'))
|
||||
self.failIf(u.checkPassword('somethingelse'))
|
||||
self.assertTrue(u.checkPassword('foobar'))
|
||||
self.assertFalse(u.checkPassword('somethingelse'))
|
||||
|
||||
def testTimeoutAuth(self):
|
||||
orig = conf.supybot.databases.users.timeoutIdentification()
|
||||
@ -247,9 +247,9 @@ class IrcUserTestCase(IrcdbTestCase):
|
||||
conf.supybot.databases.users.timeoutIdentification.setValue(2)
|
||||
u = ircdb.IrcUser()
|
||||
u.addAuth('foo!bar@baz')
|
||||
self.failUnless(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
timeFastForward(2.1)
|
||||
self.failIf(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertFalse(u.checkHostmask('foo!bar@baz'))
|
||||
finally:
|
||||
conf.supybot.databases.users.timeoutIdentification.setValue(orig)
|
||||
|
||||
@ -259,46 +259,46 @@ class IrcUserTestCase(IrcdbTestCase):
|
||||
conf.supybot.databases.users.timeoutIdentification.setValue(2)
|
||||
u = ircdb.IrcUser()
|
||||
u.addAuth('foo!bar@baz')
|
||||
self.failUnless(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
u.addAuth('foo!bar@baz')
|
||||
self.failUnless(u.checkHostmask('foo!bar@baz'))
|
||||
self.failUnless(len(u.auth) == 1)
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertTrue(len(u.auth) == 1)
|
||||
u.addAuth('boo!far@fizz')
|
||||
self.failUnless(u.checkHostmask('boo!far@fizz'))
|
||||
self.assertTrue(u.checkHostmask('boo!far@fizz'))
|
||||
timeFastForward(2.1)
|
||||
self.failIf(u.checkHostmask('foo!bar@baz'))
|
||||
self.failIf(u.checkHostmask('boo!far@fizz'))
|
||||
self.assertFalse(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertFalse(u.checkHostmask('boo!far@fizz'))
|
||||
finally:
|
||||
conf.supybot.databases.users.timeoutIdentification.setValue(orig)
|
||||
|
||||
def testHashedPassword(self):
|
||||
u = ircdb.IrcUser()
|
||||
u.setPassword('foobar', hashed=True)
|
||||
self.failUnless(u.checkPassword('foobar'))
|
||||
self.failIf(u.checkPassword('somethingelse'))
|
||||
self.assertTrue(u.checkPassword('foobar'))
|
||||
self.assertFalse(u.checkPassword('somethingelse'))
|
||||
self.assertNotEqual(u.password, 'foobar')
|
||||
|
||||
def testHostmasks(self):
|
||||
prefix = 'foo12341234!bar@baz.domain.tld'
|
||||
hostmasks = ['*!bar@baz.domain.tld', 'foo12341234!*@*']
|
||||
u = ircdb.IrcUser()
|
||||
self.failIf(u.checkHostmask(prefix))
|
||||
self.assertFalse(u.checkHostmask(prefix))
|
||||
for hostmask in hostmasks:
|
||||
u.addHostmask(hostmask)
|
||||
self.failUnless(u.checkHostmask(prefix))
|
||||
self.assertTrue(u.checkHostmask(prefix))
|
||||
|
||||
def testAuth(self):
|
||||
prefix = 'foo!bar@baz'
|
||||
u = ircdb.IrcUser()
|
||||
u.addAuth(prefix)
|
||||
self.failUnless(u.auth)
|
||||
self.assertTrue(u.auth)
|
||||
u.clearAuth()
|
||||
self.failIf(u.auth)
|
||||
self.assertFalse(u.auth)
|
||||
|
||||
def testIgnore(self):
|
||||
u = ircdb.IrcUser(ignore=True)
|
||||
self.failIf(u._checkCapability('foo'))
|
||||
self.failUnless(u._checkCapability('-foo'))
|
||||
self.assertFalse(u._checkCapability('foo'))
|
||||
self.assertTrue(u._checkCapability('-foo'))
|
||||
|
||||
def testRemoveCapability(self):
|
||||
u = ircdb.IrcUser(capabilities=('foo',))
|
||||
@ -307,45 +307,45 @@ class IrcUserTestCase(IrcdbTestCase):
|
||||
class IrcChannelTestCase(IrcdbTestCase):
|
||||
def testInit(self):
|
||||
c = ircdb.IrcChannel()
|
||||
self.failIf(c._checkCapability('op'))
|
||||
self.failIf(c._checkCapability('voice'))
|
||||
self.failIf(c._checkCapability('halfop'))
|
||||
self.failIf(c._checkCapability('protected'))
|
||||
self.assertFalse(c._checkCapability('op'))
|
||||
self.assertFalse(c._checkCapability('voice'))
|
||||
self.assertFalse(c._checkCapability('halfop'))
|
||||
self.assertFalse(c._checkCapability('protected'))
|
||||
|
||||
def testCapabilities(self):
|
||||
c = ircdb.IrcChannel(defaultAllow=False)
|
||||
self.failIf(c._checkCapability('foo'))
|
||||
self.assertFalse(c._checkCapability('foo'))
|
||||
c.addCapability('foo')
|
||||
self.failUnless(c._checkCapability('foo'))
|
||||
self.assertTrue(c._checkCapability('foo'))
|
||||
c.removeCapability('foo')
|
||||
self.failIf(c._checkCapability('foo'))
|
||||
self.assertFalse(c._checkCapability('foo'))
|
||||
|
||||
def testDefaultCapability(self):
|
||||
c = ircdb.IrcChannel()
|
||||
c.setDefaultCapability(False)
|
||||
self.failIf(c._checkCapability('foo'))
|
||||
self.failUnless(c._checkCapability('-foo'))
|
||||
self.assertFalse(c._checkCapability('foo'))
|
||||
self.assertTrue(c._checkCapability('-foo'))
|
||||
c.setDefaultCapability(True)
|
||||
self.failUnless(c._checkCapability('foo'))
|
||||
self.failIf(c._checkCapability('-foo'))
|
||||
self.assertTrue(c._checkCapability('foo'))
|
||||
self.assertFalse(c._checkCapability('-foo'))
|
||||
|
||||
def testLobotomized(self):
|
||||
c = ircdb.IrcChannel(lobotomized=True)
|
||||
self.failUnless(c.checkIgnored('foo!bar@baz'))
|
||||
self.assertTrue(c.checkIgnored('foo!bar@baz'))
|
||||
|
||||
def testIgnored(self):
|
||||
prefix = 'foo!bar@baz'
|
||||
banmask = ircutils.banmask(prefix)
|
||||
c = ircdb.IrcChannel()
|
||||
self.failIf(c.checkIgnored(prefix))
|
||||
self.assertFalse(c.checkIgnored(prefix))
|
||||
c.addIgnore(banmask)
|
||||
self.failUnless(c.checkIgnored(prefix))
|
||||
self.assertTrue(c.checkIgnored(prefix))
|
||||
c.removeIgnore(banmask)
|
||||
self.failIf(c.checkIgnored(prefix))
|
||||
self.assertFalse(c.checkIgnored(prefix))
|
||||
c.addBan(banmask)
|
||||
self.failUnless(c.checkIgnored(prefix))
|
||||
self.assertTrue(c.checkIgnored(prefix))
|
||||
c.removeBan(banmask)
|
||||
self.failIf(c.checkIgnored(prefix))
|
||||
self.assertFalse(c.checkIgnored(prefix))
|
||||
|
||||
class UsersDictionaryTestCase(IrcdbTestCase):
|
||||
filename = os.path.join(conf.supybot.directories.conf(),
|
||||
@ -483,13 +483,13 @@ class CheckCapabilityTestCase(IrcdbTestCase):
|
||||
self.users, self.channels)
|
||||
|
||||
def testOwner(self):
|
||||
self.failUnless(self.checkCapability(self.owner, self.cap))
|
||||
self.failIf(self.checkCapability(self.owner, self.anticap))
|
||||
self.failUnless(self.checkCapability(self.owner, self.chancap))
|
||||
self.failIf(self.checkCapability(self.owner, self.antichancap))
|
||||
self.assertTrue(self.checkCapability(self.owner, self.cap))
|
||||
self.assertFalse(self.checkCapability(self.owner, self.anticap))
|
||||
self.assertTrue(self.checkCapability(self.owner, self.chancap))
|
||||
self.assertFalse(self.checkCapability(self.owner, self.antichancap))
|
||||
self.channels.setChannel(self.channel, self.channelanticap)
|
||||
self.failUnless(self.checkCapability(self.owner, self.cap))
|
||||
self.failIf(self.checkCapability(self.owner, self.anticap))
|
||||
self.assertTrue(self.checkCapability(self.owner, self.cap))
|
||||
self.assertFalse(self.checkCapability(self.owner, self.anticap))
|
||||
|
||||
def testNothingAgainstChannel(self):
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
@ -500,11 +500,11 @@ class CheckCapabilityTestCase(IrcdbTestCase):
|
||||
self.assertEqual(self.checkCapability(self.nothing, self.chancap),
|
||||
self.channelnothing.defaultAllow)
|
||||
self.channels.setChannel(self.channel, self.channelcap)
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.failIf(self.checkCapability(self.nothing, self.antichancap))
|
||||
self.assertTrue(self.checkCapability(self.nothing, self.chancap))
|
||||
self.assertFalse(self.checkCapability(self.nothing, self.antichancap))
|
||||
self.channels.setChannel(self.channel, self.channelanticap)
|
||||
self.failIf(self.checkCapability(self.nothing, self.chancap))
|
||||
self.failUnless(self.checkCapability(self.nothing, self.antichancap))
|
||||
self.assertFalse(self.checkCapability(self.nothing, self.chancap))
|
||||
self.assertTrue(self.checkCapability(self.nothing, self.antichancap))
|
||||
|
||||
def testNothing(self):
|
||||
self.assertEqual(self.checkCapability(self.nothing, self.cap),
|
||||
@ -513,23 +513,23 @@ class CheckCapabilityTestCase(IrcdbTestCase):
|
||||
not conf.supybot.capabilities.default())
|
||||
|
||||
def testJustFoo(self):
|
||||
self.failUnless(self.checkCapability(self.justfoo, self.cap))
|
||||
self.failIf(self.checkCapability(self.justfoo, self.anticap))
|
||||
self.assertTrue(self.checkCapability(self.justfoo, self.cap))
|
||||
self.assertFalse(self.checkCapability(self.justfoo, self.anticap))
|
||||
|
||||
def testAntiFoo(self):
|
||||
self.failUnless(self.checkCapability(self.antifoo, self.anticap))
|
||||
self.failIf(self.checkCapability(self.antifoo, self.cap))
|
||||
self.assertTrue(self.checkCapability(self.antifoo, self.anticap))
|
||||
self.assertFalse(self.checkCapability(self.antifoo, self.cap))
|
||||
|
||||
def testJustChanFoo(self):
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
self.failUnless(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.failIf(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
self.assertTrue(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.assertFalse(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
self.channelnothing.defaultAllow = not self.channelnothing.defaultAllow
|
||||
self.failUnless(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.failIf(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
self.assertTrue(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.assertFalse(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
self.channels.setChannel(self.channel, self.channelanticap)
|
||||
self.failUnless(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.failIf(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
self.assertTrue(self.checkCapability(self.justchanfoo, self.chancap))
|
||||
self.assertFalse(self.checkCapability(self.justchanfoo, self.antichancap))
|
||||
|
||||
def testChanOpCountsAsEverything(self):
|
||||
self.channels.setChannel(self.channel, self.channelanticap)
|
||||
@ -537,20 +537,20 @@ class CheckCapabilityTestCase(IrcdbTestCase):
|
||||
u = self.users.getUser(id)
|
||||
u.addCapability(self.chanop)
|
||||
self.users.setUser(u)
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.assertTrue(self.checkCapability(self.nothing, self.chancap))
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.assertTrue(self.checkCapability(self.nothing, self.chancap))
|
||||
self.channelnothing.defaultAllow = not self.channelnothing.defaultAllow
|
||||
self.failUnless(self.checkCapability(self.nothing, self.chancap))
|
||||
self.assertTrue(self.checkCapability(self.nothing, self.chancap))
|
||||
|
||||
def testAntiChanFoo(self):
|
||||
self.channels.setChannel(self.channel, self.channelnothing)
|
||||
self.failIf(self.checkCapability(self.antichanfoo, self.chancap))
|
||||
self.failUnless(self.checkCapability(self.antichanfoo,
|
||||
self.assertFalse(self.checkCapability(self.antichanfoo, self.chancap))
|
||||
self.assertTrue(self.checkCapability(self.antichanfoo,
|
||||
self.antichancap))
|
||||
|
||||
def testSecurefoo(self):
|
||||
self.failUnless(self.checkCapability(self.securefoo, self.cap))
|
||||
self.assertTrue(self.checkCapability(self.securefoo, self.cap))
|
||||
id = self.users.getUserId(self.securefoo)
|
||||
u = self.users.getUser(id)
|
||||
u.addAuth(self.securefoo)
|
||||
@ -558,7 +558,7 @@ class CheckCapabilityTestCase(IrcdbTestCase):
|
||||
try:
|
||||
originalConfDefaultAllow = conf.supybot.capabilities.default()
|
||||
conf.supybot.capabilities.default.set('False')
|
||||
self.failIf(self.checkCapability('a' + self.securefoo, self.cap))
|
||||
self.assertFalse(self.checkCapability('a' + self.securefoo, self.cap))
|
||||
finally:
|
||||
conf.supybot.capabilities.default.set(str(originalConfDefaultAllow))
|
||||
|
||||
|
@ -169,13 +169,13 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.msg)
|
||||
self.failUnless(self.msg in q)
|
||||
self.assertTrue(self.msg in q)
|
||||
q.dequeue()
|
||||
self.failUnless(self.msg in q)
|
||||
self.assertTrue(self.msg in q)
|
||||
q.dequeue()
|
||||
self.failUnless(self.msg in q)
|
||||
self.assertTrue(self.msg in q)
|
||||
q.dequeue()
|
||||
self.failIf(self.msg in q)
|
||||
self.assertFalse(self.msg in q)
|
||||
|
||||
def testRepr(self):
|
||||
q = irclib.IrcMsgQueue()
|
||||
@ -189,14 +189,14 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
||||
|
||||
def testEmpty(self):
|
||||
q = irclib.IrcMsgQueue()
|
||||
self.failIf(q)
|
||||
self.assertFalse(q)
|
||||
|
||||
def testEnqueueDequeue(self):
|
||||
q = irclib.IrcMsgQueue()
|
||||
q.enqueue(self.msg)
|
||||
self.failUnless(q)
|
||||
self.assertTrue(q)
|
||||
self.assertEqual(self.msg, q.dequeue())
|
||||
self.failIf(q)
|
||||
self.assertFalse(q)
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.notice)
|
||||
self.assertEqual(self.msg, q.dequeue())
|
||||
@ -236,7 +236,7 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.msg)
|
||||
self.assertEqual(self.msg, q.dequeue())
|
||||
self.failIf(q)
|
||||
self.assertFalse(q)
|
||||
finally:
|
||||
configVar.setValue(original)
|
||||
|
||||
@ -278,39 +278,39 @@ class ChannelStateTestCase(SupyTestCase):
|
||||
c1 = pickle.loads(pickle.dumps(c))
|
||||
self.assertEqual(c, c1)
|
||||
c.removeUser('jemfinch')
|
||||
self.failIf('jemfinch' in c.users)
|
||||
self.failUnless('jemfinch' in c1.users)
|
||||
self.assertFalse('jemfinch' in c.users)
|
||||
self.assertTrue('jemfinch' in c1.users)
|
||||
|
||||
def testCopy(self):
|
||||
c = irclib.ChannelState()
|
||||
c.addUser('jemfinch')
|
||||
c1 = copy.deepcopy(c)
|
||||
c.removeUser('jemfinch')
|
||||
self.failIf('jemfinch' in c.users)
|
||||
self.failUnless('jemfinch' in c1.users)
|
||||
self.assertFalse('jemfinch' in c.users)
|
||||
self.assertTrue('jemfinch' in c1.users)
|
||||
|
||||
def testAddUser(self):
|
||||
c = irclib.ChannelState()
|
||||
c.addUser('foo')
|
||||
self.failUnless('foo' in c.users)
|
||||
self.failIf('foo' in c.ops)
|
||||
self.failIf('foo' in c.voices)
|
||||
self.failIf('foo' in c.halfops)
|
||||
self.assertTrue('foo' in c.users)
|
||||
self.assertFalse('foo' in c.ops)
|
||||
self.assertFalse('foo' in c.voices)
|
||||
self.assertFalse('foo' in c.halfops)
|
||||
c.addUser('+bar')
|
||||
self.failUnless('bar' in c.users)
|
||||
self.failUnless('bar' in c.voices)
|
||||
self.failIf('bar' in c.ops)
|
||||
self.failIf('bar' in c.halfops)
|
||||
self.assertTrue('bar' in c.users)
|
||||
self.assertTrue('bar' in c.voices)
|
||||
self.assertFalse('bar' in c.ops)
|
||||
self.assertFalse('bar' in c.halfops)
|
||||
c.addUser('%baz')
|
||||
self.failUnless('baz' in c.users)
|
||||
self.failUnless('baz' in c.halfops)
|
||||
self.failIf('baz' in c.voices)
|
||||
self.failIf('baz' in c.ops)
|
||||
self.assertTrue('baz' in c.users)
|
||||
self.assertTrue('baz' in c.halfops)
|
||||
self.assertFalse('baz' in c.voices)
|
||||
self.assertFalse('baz' in c.ops)
|
||||
c.addUser('@quuz')
|
||||
self.failUnless('quuz' in c.users)
|
||||
self.failUnless('quuz' in c.ops)
|
||||
self.failIf('quuz' in c.halfops)
|
||||
self.failIf('quuz' in c.voices)
|
||||
self.assertTrue('quuz' in c.users)
|
||||
self.assertTrue('quuz' in c.ops)
|
||||
self.assertFalse('quuz' in c.halfops)
|
||||
self.assertFalse('quuz' in c.voices)
|
||||
|
||||
|
||||
class IrcStateTestCase(SupyTestCase):
|
||||
@ -327,7 +327,7 @@ class IrcStateTestCase(SupyTestCase):
|
||||
st.channels['#foo'] = irclib.ChannelState()
|
||||
m = ircmsgs.kick('#foo', self.irc.nick, prefix=self.irc.prefix)
|
||||
st.addMsg(self.irc, m)
|
||||
self.failIf('#foo' in st.channels)
|
||||
self.assertFalse('#foo' in st.channels)
|
||||
|
||||
def testAddMsgRemovesOpsProperly(self):
|
||||
st = irclib.IrcState()
|
||||
@ -335,19 +335,19 @@ class IrcStateTestCase(SupyTestCase):
|
||||
st.channels['#foo'].ops.add('bar')
|
||||
m = ircmsgs.mode('#foo', ('-o', 'bar'))
|
||||
st.addMsg(self.irc, m)
|
||||
self.failIf('bar' in st.channels['#foo'].ops)
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
|
||||
def testNickChangesChangeChannelUsers(self):
|
||||
st = irclib.IrcState()
|
||||
st.channels['#foo'] = irclib.ChannelState()
|
||||
st.channels['#foo'].addUser('@bar')
|
||||
self.failUnless('bar' in st.channels['#foo'].users)
|
||||
self.failUnless(st.channels['#foo'].isOp('bar'))
|
||||
self.assertTrue('bar' in st.channels['#foo'].users)
|
||||
self.assertTrue(st.channels['#foo'].isOp('bar'))
|
||||
st.addMsg(self.irc, ircmsgs.IrcMsg(':bar!asfd@asdf.com NICK baz'))
|
||||
self.failIf('bar' in st.channels['#foo'].users)
|
||||
self.failIf(st.channels['#foo'].isOp('bar'))
|
||||
self.failUnless('baz' in st.channels['#foo'].users)
|
||||
self.failUnless(st.channels['#foo'].isOp('baz'))
|
||||
self.assertFalse('bar' in st.channels['#foo'].users)
|
||||
self.assertFalse(st.channels['#foo'].isOp('bar'))
|
||||
self.assertTrue('baz' in st.channels['#foo'].users)
|
||||
self.assertTrue(st.channels['#foo'].isOp('baz'))
|
||||
|
||||
def testHistory(self):
|
||||
if len(msgs) < 10:
|
||||
@ -360,7 +360,7 @@ class IrcStateTestCase(SupyTestCase):
|
||||
state.addMsg(self.irc, msg)
|
||||
except Exception:
|
||||
pass
|
||||
self.failIf(len(state.history) > maxHistoryLength())
|
||||
self.assertFalse(len(state.history) > maxHistoryLength())
|
||||
self.assertEqual(len(state.history), maxHistoryLength())
|
||||
self.assertEqual(list(state.history),
|
||||
msgs[len(msgs) - maxHistoryLength():])
|
||||
@ -414,19 +414,19 @@ class IrcStateTestCase(SupyTestCase):
|
||||
state = irclib.IrcState()
|
||||
stateCopy = state.copy()
|
||||
state.channels['#foo'] = None
|
||||
self.failIf('#foo' in stateCopy.channels)
|
||||
self.assertFalse('#foo' in stateCopy.channels)
|
||||
|
||||
def testJoin(self):
|
||||
st = irclib.IrcState()
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix))
|
||||
self.failUnless('#foo' in st.channels)
|
||||
self.failUnless(self.irc.nick in st.channels['#foo'].users)
|
||||
self.assertTrue('#foo' in st.channels)
|
||||
self.assertTrue(self.irc.nick in st.channels['#foo'].users)
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix='foo!bar@baz'))
|
||||
self.failUnless('foo' in st.channels['#foo'].users)
|
||||
self.assertTrue('foo' in st.channels['#foo'].users)
|
||||
st2 = st.copy()
|
||||
st.addMsg(self.irc, ircmsgs.quit(prefix='foo!bar@baz'))
|
||||
self.failIf('foo' in st.channels['#foo'].users)
|
||||
self.failUnless('foo' in st2.channels['#foo'].users)
|
||||
self.assertFalse('foo' in st.channels['#foo'].users)
|
||||
self.assertTrue('foo' in st2.channels['#foo'].users)
|
||||
|
||||
|
||||
def testEq(self):
|
||||
@ -444,23 +444,23 @@ class IrcStateTestCase(SupyTestCase):
|
||||
def testHandlesModes(self):
|
||||
st = irclib.IrcState()
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix))
|
||||
self.failIf('bar' in st.channels['#foo'].ops)
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
st.addMsg(self.irc, ircmsgs.op('#foo', 'bar'))
|
||||
self.failUnless('bar' in st.channels['#foo'].ops)
|
||||
self.assertTrue('bar' in st.channels['#foo'].ops)
|
||||
st.addMsg(self.irc, ircmsgs.deop('#foo', 'bar'))
|
||||
self.failIf('bar' in st.channels['#foo'].ops)
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
|
||||
self.failIf('bar' in st.channels['#foo'].voices)
|
||||
self.assertFalse('bar' in st.channels['#foo'].voices)
|
||||
st.addMsg(self.irc, ircmsgs.voice('#foo', 'bar'))
|
||||
self.failUnless('bar' in st.channels['#foo'].voices)
|
||||
self.assertTrue('bar' in st.channels['#foo'].voices)
|
||||
st.addMsg(self.irc, ircmsgs.devoice('#foo', 'bar'))
|
||||
self.failIf('bar' in st.channels['#foo'].voices)
|
||||
self.assertFalse('bar' in st.channels['#foo'].voices)
|
||||
|
||||
self.failIf('bar' in st.channels['#foo'].halfops)
|
||||
self.assertFalse('bar' in st.channels['#foo'].halfops)
|
||||
st.addMsg(self.irc, ircmsgs.halfop('#foo', 'bar'))
|
||||
self.failUnless('bar' in st.channels['#foo'].halfops)
|
||||
self.assertTrue('bar' in st.channels['#foo'].halfops)
|
||||
st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar'))
|
||||
self.failIf('bar' in st.channels['#foo'].halfops)
|
||||
self.assertFalse('bar' in st.channels['#foo'].halfops)
|
||||
|
||||
def testDoModeOnlyChannels(self):
|
||||
st = irclib.IrcState()
|
||||
@ -471,14 +471,14 @@ class IrcCapsTestCase(SupyTestCase):
|
||||
self.irc = irclib.Irc('test')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.failUnless(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
self.irc.REQUEST_CAPABILITIES = set(['a'*400, 'b'*400])
|
||||
caps = ' '.join(self.irc.REQUEST_CAPABILITIES)
|
||||
@ -488,12 +488,12 @@ class IrcCapsTestCase(SupyTestCase):
|
||||
args=('*', 'LS', 'b'*400)))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'a'*400)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'b'*400)
|
||||
|
||||
@ -502,17 +502,17 @@ class IrcTestCase(SupyTestCase):
|
||||
self.irc = irclib.Irc('test')
|
||||
|
||||
#m = self.irc.takeMsg()
|
||||
#self.failUnless(m.command == 'PASS', 'Expected PASS, got %r.' % m)
|
||||
#self.assertTrue(m.command == 'PASS', 'Expected PASS, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.failUnless(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
# TODO
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||
@ -521,7 +521,7 @@ class IrcTestCase(SupyTestCase):
|
||||
args=('*', 'LS', 'extended-join')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
# NOTE: Capabilities are requested in alphabetic order, because
|
||||
# sets are unordered, and their "order" is nondeterministic.
|
||||
@ -531,11 +531,11 @@ class IrcTestCase(SupyTestCase):
|
||||
args=('*', 'ACK', 'account-tag multi-prefix extended-join')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('END',), m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m is None, m)
|
||||
self.assertTrue(m is None, m)
|
||||
|
||||
def testPingResponse(self):
|
||||
self.irc.feedMsg(ircmsgs.ping('123'))
|
||||
@ -547,11 +547,11 @@ class IrcTestCase(SupyTestCase):
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\
|
||||
self.irc.nick))
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(msg.command == 'NICK' and msg.args[0] != self.irc.nick)
|
||||
self.assertTrue(msg.command == 'NICK' and msg.args[0] != self.irc.nick)
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\
|
||||
self.irc.nick))
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(msg.command == 'NICK' and msg.args[0] != self.irc.nick)
|
||||
self.assertTrue(msg.command == 'NICK' and msg.args[0] != self.irc.nick)
|
||||
|
||||
def testSendBeforeQueue(self):
|
||||
while self.irc.takeMsg() is not None:
|
||||
@ -559,14 +559,14 @@ class IrcTestCase(SupyTestCase):
|
||||
self.irc.queueMsg(ircmsgs.IrcMsg('NOTICE #foo bar'))
|
||||
self.irc.sendMsg(ircmsgs.IrcMsg('PRIVMSG #foo yeah!'))
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(msg.command == 'PRIVMSG')
|
||||
self.assertTrue(msg.command == 'PRIVMSG')
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(msg.command == 'NOTICE')
|
||||
self.assertTrue(msg.command == 'NOTICE')
|
||||
|
||||
def testNoMsgLongerThan512(self):
|
||||
self.irc.queueMsg(ircmsgs.privmsg('whocares', 'x'*1000))
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(len(msg) <= 512, 'len(msg) was %s' % len(msg))
|
||||
self.assertTrue(len(msg) <= 512, 'len(msg) was %s' % len(msg))
|
||||
|
||||
def testReset(self):
|
||||
for msg in msgs:
|
||||
@ -575,9 +575,9 @@ class IrcTestCase(SupyTestCase):
|
||||
except:
|
||||
pass
|
||||
self.irc.reset()
|
||||
self.failIf(self.irc.state.history)
|
||||
self.failIf(self.irc.state.channels)
|
||||
self.failIf(self.irc.outstandingPing)
|
||||
self.assertFalse(self.irc.state.history)
|
||||
self.assertFalse(self.irc.state.channels)
|
||||
self.assertFalse(self.irc.outstandingPing)
|
||||
|
||||
def testHistory(self):
|
||||
self.irc.reset()
|
||||
@ -691,21 +691,21 @@ class SaslTestCase(SupyTestCase):
|
||||
|
||||
def startCapNegociation(self, caps='sasl'):
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.failUnless(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||
args=('*', 'LS', caps)))
|
||||
|
||||
if caps:
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'sasl')
|
||||
|
||||
@ -714,7 +714,7 @@ class SaslTestCase(SupyTestCase):
|
||||
|
||||
def endCapNegociation(self):
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('END',), m)
|
||||
|
||||
def testPlain(self):
|
||||
@ -850,7 +850,7 @@ class SaslTestCase(SupyTestCase):
|
||||
conf.supybot.networks.test.sasl.password.setValue('')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.failUnless(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'sasl')
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||
|
@ -47,7 +47,7 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
for msg in msgs:
|
||||
if msg.prefix:
|
||||
strmsg = str(msg)
|
||||
self.failIf(len(msg) != len(strmsg) and \
|
||||
self.assertFalse(len(msg) != len(strmsg) and \
|
||||
strmsg.replace(':', '') == strmsg)
|
||||
|
||||
def testRepr(self):
|
||||
@ -58,17 +58,17 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
def testStr(self):
|
||||
for (rawmsg, msg) in zip(rawmsgs, msgs):
|
||||
strmsg = str(msg).strip()
|
||||
self.failIf(rawmsg != strmsg and \
|
||||
self.assertFalse(rawmsg != strmsg and \
|
||||
strmsg.replace(':', '') == strmsg)
|
||||
|
||||
def testEq(self):
|
||||
for msg in msgs:
|
||||
self.assertEqual(msg, msg)
|
||||
self.failIf(msgs and msgs[0] == []) # Comparison to unhashable type.
|
||||
self.assertFalse(msgs and msgs[0] == []) # Comparison to unhashable type.
|
||||
|
||||
def testNe(self):
|
||||
for msg in msgs:
|
||||
self.failIf(msg != msg)
|
||||
self.assertFalse(msg != msg)
|
||||
|
||||
## def testImmutability(self):
|
||||
## s = 'something else'
|
||||
@ -111,7 +111,7 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
for msg in msgs:
|
||||
if hash(msg) == 0:
|
||||
zeroes += 1
|
||||
self.failIf(zeroes > (len(msgs)/10), 'Too many zero hashes.')
|
||||
self.assertFalse(zeroes > (len(msgs)/10), 'Too many zero hashes.')
|
||||
|
||||
def testMsgKeywordHandledProperly(self):
|
||||
msg = ircmsgs.notice('foo', 'bar')
|
||||
@ -126,11 +126,11 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
|
||||
def testTags(self):
|
||||
m = ircmsgs.privmsg('foo', 'bar')
|
||||
self.failIf(m.repliedTo)
|
||||
self.assertFalse(m.repliedTo)
|
||||
m.tag('repliedTo')
|
||||
self.failUnless(m.repliedTo)
|
||||
self.assertTrue(m.repliedTo)
|
||||
m.tag('repliedTo')
|
||||
self.failUnless(m.repliedTo)
|
||||
self.assertTrue(m.repliedTo)
|
||||
m.tag('repliedTo', 12)
|
||||
self.assertEqual(m.repliedTo, 12)
|
||||
|
||||
@ -177,22 +177,22 @@ class FunctionsTestCase(SupyTestCase):
|
||||
':ACTION resizes angryman\'s terminal to 40x24 (#16)']
|
||||
msgs = list(map(ircmsgs.IrcMsg, L))
|
||||
for msg in msgs:
|
||||
self.failUnless(ircmsgs.isAction(msg))
|
||||
self.assertTrue(ircmsgs.isAction(msg))
|
||||
|
||||
def testIsActionIsntStupid(self):
|
||||
m = ircmsgs.privmsg('#x', '\x01NOTANACTION foo\x01')
|
||||
self.failIf(ircmsgs.isAction(m))
|
||||
self.assertFalse(ircmsgs.isAction(m))
|
||||
m = ircmsgs.privmsg('#x', '\x01ACTION foo bar\x01')
|
||||
self.failUnless(ircmsgs.isAction(m))
|
||||
self.assertTrue(ircmsgs.isAction(m))
|
||||
|
||||
def testIsCtcp(self):
|
||||
self.failUnless(ircmsgs.isCtcp(ircmsgs.privmsg('foo',
|
||||
self.assertTrue(ircmsgs.isCtcp(ircmsgs.privmsg('foo',
|
||||
'\x01VERSION\x01')))
|
||||
self.failIf(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01')))
|
||||
self.assertFalse(ircmsgs.isCtcp(ircmsgs.privmsg('foo', '\x01')))
|
||||
|
||||
def testIsActionFalseWhenNoSpaces(self):
|
||||
msg = ircmsgs.IrcMsg('PRIVMSG #foo :\x01ACTIONfoobar\x01')
|
||||
self.failIf(ircmsgs.isAction(msg))
|
||||
self.assertFalse(ircmsgs.isAction(msg))
|
||||
|
||||
def testUnAction(self):
|
||||
s = 'foo bar baz'
|
||||
@ -259,7 +259,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
('#osu,#umich', 'michiganSucks'))
|
||||
|
||||
def testQuit(self):
|
||||
self.failUnless(ircmsgs.quit(prefix='foo!bar@baz'))
|
||||
self.assertTrue(ircmsgs.quit(prefix='foo!bar@baz'))
|
||||
|
||||
def testOps(self):
|
||||
m = ircmsgs.ops('#foo', ['foo', 'bar', 'baz'])
|
||||
@ -294,15 +294,15 @@ class FunctionsTestCase(SupyTestCase):
|
||||
m = ircmsgs.IrcMsg(prefix="caker!~caker@ns.theshore.net",
|
||||
command="QUIT",
|
||||
args=('jupiter.oftc.net quasar.oftc.net',))
|
||||
self.failUnless(ircmsgs.isSplit(m))
|
||||
self.assertTrue(ircmsgs.isSplit(m))
|
||||
m = ircmsgs.IrcMsg(prefix="bzbot!Brad2901@ACC87473.ipt.aol.com",
|
||||
command="QUIT",
|
||||
args=('Read error: 110 (Connection timed out)',))
|
||||
self.failIf(ircmsgs.isSplit(m))
|
||||
self.assertFalse(ircmsgs.isSplit(m))
|
||||
m = ircmsgs.IrcMsg(prefix="JibberJim!~none@8212cl.b0nwbeoe.co.uk",
|
||||
command="QUIT",
|
||||
args=('"Bye!"',))
|
||||
self.failIf(ircmsgs.isSplit(m))
|
||||
self.assertFalse(ircmsgs.isSplit(m))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -47,47 +47,47 @@ class FunctionsTestCase(SupyTestCase):
|
||||
for msg in msgs:
|
||||
if msg.prefix and ircutils.isUserHostmask(msg.prefix):
|
||||
s = msg.prefix
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s),
|
||||
self.assertTrue(ircutils.hostmaskPatternEqual(s, s),
|
||||
'%r did not match itself.' % s)
|
||||
banmask = ircutils.banmask(s)
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(banmask, s),
|
||||
self.assertTrue(ircutils.hostmaskPatternEqual(banmask, s),
|
||||
'%r did not match %r' % (s, banmask))
|
||||
s = 'supybot!~supybot@dhcp065-024-075-056.columbus.rr.com'
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
||||
self.assertTrue(ircutils.hostmaskPatternEqual(s, s))
|
||||
s = 'jamessan|work!~jamessan@209-6-166-196.c3-0.' \
|
||||
'abr-ubr1.sbo-abr.ma.cable.rcn.com'
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(s, s))
|
||||
self.assertTrue(ircutils.hostmaskPatternEqual(s, s))
|
||||
|
||||
def testIsUserHostmask(self):
|
||||
self.failUnless(ircutils.isUserHostmask(self.hostmask))
|
||||
self.failUnless(ircutils.isUserHostmask('a!b@c'))
|
||||
self.failIf(ircutils.isUserHostmask('!bar@baz'))
|
||||
self.failIf(ircutils.isUserHostmask('!@baz'))
|
||||
self.failIf(ircutils.isUserHostmask('!bar@'))
|
||||
self.failIf(ircutils.isUserHostmask('!@'))
|
||||
self.failIf(ircutils.isUserHostmask('foo!@baz'))
|
||||
self.failIf(ircutils.isUserHostmask('foo!bar@'))
|
||||
self.failIf(ircutils.isUserHostmask(''))
|
||||
self.failIf(ircutils.isUserHostmask('!'))
|
||||
self.failIf(ircutils.isUserHostmask('@'))
|
||||
self.failIf(ircutils.isUserHostmask('!bar@baz'))
|
||||
self.assertTrue(ircutils.isUserHostmask(self.hostmask))
|
||||
self.assertTrue(ircutils.isUserHostmask('a!b@c'))
|
||||
self.assertFalse(ircutils.isUserHostmask('!bar@baz'))
|
||||
self.assertFalse(ircutils.isUserHostmask('!@baz'))
|
||||
self.assertFalse(ircutils.isUserHostmask('!bar@'))
|
||||
self.assertFalse(ircutils.isUserHostmask('!@'))
|
||||
self.assertFalse(ircutils.isUserHostmask('foo!@baz'))
|
||||
self.assertFalse(ircutils.isUserHostmask('foo!bar@'))
|
||||
self.assertFalse(ircutils.isUserHostmask(''))
|
||||
self.assertFalse(ircutils.isUserHostmask('!'))
|
||||
self.assertFalse(ircutils.isUserHostmask('@'))
|
||||
self.assertFalse(ircutils.isUserHostmask('!bar@baz'))
|
||||
|
||||
def testIsChannel(self):
|
||||
self.failUnless(ircutils.isChannel('#'))
|
||||
self.failUnless(ircutils.isChannel('&'))
|
||||
self.failIf(ircutils.isChannel('+'))
|
||||
self.failUnless(ircutils.isChannel('+', chantypes='#&+!'))
|
||||
self.failUnless(ircutils.isChannel('!'))
|
||||
self.failUnless(ircutils.isChannel('#foo'))
|
||||
self.failUnless(ircutils.isChannel('&foo'))
|
||||
self.failIf(ircutils.isChannel('+foo'))
|
||||
self.failUnless(ircutils.isChannel('+foo', chantypes='#&+!'))
|
||||
self.failUnless(ircutils.isChannel('!foo'))
|
||||
self.failIf(ircutils.isChannel('#foo bar'))
|
||||
self.failIf(ircutils.isChannel('#foo,bar'))
|
||||
self.failIf(ircutils.isChannel('#foobar\x07'))
|
||||
self.failIf(ircutils.isChannel('foo'))
|
||||
self.failIf(ircutils.isChannel(''))
|
||||
self.assertTrue(ircutils.isChannel('#'))
|
||||
self.assertTrue(ircutils.isChannel('&'))
|
||||
self.assertFalse(ircutils.isChannel('+'))
|
||||
self.assertTrue(ircutils.isChannel('+', chantypes='#&+!'))
|
||||
self.assertTrue(ircutils.isChannel('!'))
|
||||
self.assertTrue(ircutils.isChannel('#foo'))
|
||||
self.assertTrue(ircutils.isChannel('&foo'))
|
||||
self.assertFalse(ircutils.isChannel('+foo'))
|
||||
self.assertTrue(ircutils.isChannel('+foo', chantypes='#&+!'))
|
||||
self.assertTrue(ircutils.isChannel('!foo'))
|
||||
self.assertFalse(ircutils.isChannel('#foo bar'))
|
||||
self.assertFalse(ircutils.isChannel('#foo,bar'))
|
||||
self.assertFalse(ircutils.isChannel('#foobar\x07'))
|
||||
self.assertFalse(ircutils.isChannel('foo'))
|
||||
self.assertFalse(ircutils.isChannel(''))
|
||||
|
||||
def testBold(self):
|
||||
s = ircutils.bold('foo')
|
||||
@ -249,22 +249,22 @@ class FunctionsTestCase(SupyTestCase):
|
||||
try:
|
||||
original = conf.supybot.protocols.irc.strictRfc()
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(True)
|
||||
self.failUnless(ircutils.isNick('jemfinch'))
|
||||
self.failUnless(ircutils.isNick('jemfinch0'))
|
||||
self.failUnless(ircutils.isNick('[0]'))
|
||||
self.failUnless(ircutils.isNick('{jemfinch}'))
|
||||
self.failUnless(ircutils.isNick('[jemfinch]'))
|
||||
self.failUnless(ircutils.isNick('jem|finch'))
|
||||
self.failUnless(ircutils.isNick('\\```'))
|
||||
self.failUnless(ircutils.isNick('`'))
|
||||
self.failUnless(ircutils.isNick('A'))
|
||||
self.failIf(ircutils.isNick(''))
|
||||
self.failIf(ircutils.isNick('8foo'))
|
||||
self.failIf(ircutils.isNick('10'))
|
||||
self.failIf(ircutils.isNick('-'))
|
||||
self.failIf(ircutils.isNick('-foo'))
|
||||
self.assertTrue(ircutils.isNick('jemfinch'))
|
||||
self.assertTrue(ircutils.isNick('jemfinch0'))
|
||||
self.assertTrue(ircutils.isNick('[0]'))
|
||||
self.assertTrue(ircutils.isNick('{jemfinch}'))
|
||||
self.assertTrue(ircutils.isNick('[jemfinch]'))
|
||||
self.assertTrue(ircutils.isNick('jem|finch'))
|
||||
self.assertTrue(ircutils.isNick('\\```'))
|
||||
self.assertTrue(ircutils.isNick('`'))
|
||||
self.assertTrue(ircutils.isNick('A'))
|
||||
self.assertFalse(ircutils.isNick(''))
|
||||
self.assertFalse(ircutils.isNick('8foo'))
|
||||
self.assertFalse(ircutils.isNick('10'))
|
||||
self.assertFalse(ircutils.isNick('-'))
|
||||
self.assertFalse(ircutils.isNick('-foo'))
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(False)
|
||||
self.failUnless(ircutils.isNick('services@something.undernet.net'))
|
||||
self.assertTrue(ircutils.isNick('services@something.undernet.net'))
|
||||
finally:
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(original)
|
||||
|
||||
@ -272,9 +272,9 @@ class FunctionsTestCase(SupyTestCase):
|
||||
try:
|
||||
original = conf.supybot.protocols.irc.strictRfc()
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(True)
|
||||
self.failIf(ircutils.isNick('foo bar'))
|
||||
self.assertFalse(ircutils.isNick('foo bar'))
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(False)
|
||||
self.failIf(ircutils.isNick('foo bar'))
|
||||
self.assertFalse(ircutils.isNick('foo bar'))
|
||||
finally:
|
||||
conf.supybot.protocols.irc.strictRfc.setValue(original)
|
||||
|
||||
@ -306,7 +306,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
for msg in msgs:
|
||||
if ircutils.isUserHostmask(msg.prefix):
|
||||
banmask = ircutils.banmask(msg.prefix)
|
||||
self.failUnless(ircutils.hostmaskPatternEqual(banmask,
|
||||
self.assertTrue(ircutils.hostmaskPatternEqual(banmask,
|
||||
msg.prefix),
|
||||
'%r didn\'t match %r' % (msg.prefix, banmask))
|
||||
self.assertEqual(ircutils.banmask('foobar!user@host'), '*!*@host')
|
||||
@ -402,9 +402,9 @@ class IrcDictTestCase(SupyTestCase):
|
||||
def testContains(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['#FOO'] = None
|
||||
self.failUnless('#foo' in d)
|
||||
self.assertTrue('#foo' in d)
|
||||
d['#fOOBAR[]'] = None
|
||||
self.failUnless('#foobar{}' in d)
|
||||
self.assertTrue('#foobar{}' in d)
|
||||
|
||||
def testGetSetItem(self):
|
||||
d = ircutils.IrcDict()
|
||||
@ -416,8 +416,8 @@ class IrcDictTestCase(SupyTestCase):
|
||||
def testCopyable(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['foo'] = 'bar'
|
||||
self.failUnless(d == copy.copy(d))
|
||||
self.failUnless(d == copy.deepcopy(d))
|
||||
self.assertTrue(d == copy.copy(d))
|
||||
self.assertTrue(d == copy.deepcopy(d))
|
||||
|
||||
|
||||
class IrcSetTestCase(SupyTestCase):
|
||||
@ -425,30 +425,30 @@ class IrcSetTestCase(SupyTestCase):
|
||||
s = ircutils.IrcSet()
|
||||
s.add('foo')
|
||||
s.add('bar')
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('FOO' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('FOO' in s)
|
||||
s.discard('alfkj')
|
||||
s.remove('FOo')
|
||||
self.failIf('foo' in s)
|
||||
self.failIf('FOo' in s)
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('FOo' in s)
|
||||
|
||||
def testCopy(self):
|
||||
s = ircutils.IrcSet()
|
||||
s.add('foo')
|
||||
s.add('bar')
|
||||
s1 = copy.deepcopy(s)
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('FOO' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('FOO' in s)
|
||||
s.discard('alfkj')
|
||||
s.remove('FOo')
|
||||
self.failIf('foo' in s)
|
||||
self.failIf('FOo' in s)
|
||||
self.failUnless('foo' in s1)
|
||||
self.failUnless('FOO' in s1)
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('FOo' in s)
|
||||
self.assertTrue('foo' in s1)
|
||||
self.assertTrue('FOO' in s1)
|
||||
s1.discard('alfkj')
|
||||
s1.remove('FOo')
|
||||
self.failIf('foo' in s1)
|
||||
self.failIf('FOo' in s1)
|
||||
self.assertFalse('foo' in s1)
|
||||
self.assertFalse('FOo' in s1)
|
||||
|
||||
|
||||
class IrcStringTestCase(SupyTestCase):
|
||||
@ -463,8 +463,8 @@ class IrcStringTestCase(SupyTestCase):
|
||||
def testInequality(self):
|
||||
s1 = 'supybot'
|
||||
s2 = ircutils.IrcString('Supybot')
|
||||
self.failUnless(s1 == s2)
|
||||
self.failIf(s1 != s2)
|
||||
self.assertTrue(s1 == s2)
|
||||
self.assertFalse(s1 != s2)
|
||||
|
||||
class AuthenticateTestCase(SupyTestCase):
|
||||
PAIRS = [
|
||||
|
@ -34,10 +34,10 @@ import supybot.plugin as plugin
|
||||
class FunctionsTestCase(SupyTestCase):
|
||||
def testLoadPluginModule(self):
|
||||
self.assertRaises(ImportError, plugin.loadPluginModule, 'asldj')
|
||||
self.failUnless(plugin.loadPluginModule('Owner'))
|
||||
self.assertTrue(plugin.loadPluginModule('Owner'))
|
||||
# I haven't yet figured out a way to get case-insensitivity back for
|
||||
# "directoried" plugins.
|
||||
#self.failUnless(plugin.loadPluginModule('owner'))
|
||||
#self.assertTrue(plugin.loadPluginModule('owner'))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -74,25 +74,25 @@ class FunctionsTestCase(SupyTestCase):
|
||||
class ValuesTestCase(SupyTestCase):
|
||||
def testBoolean(self):
|
||||
v = registry.Boolean(True, """Help""")
|
||||
self.failUnless(v())
|
||||
self.assertTrue(v())
|
||||
v.setValue(False)
|
||||
self.failIf(v())
|
||||
self.assertFalse(v())
|
||||
v.set('True')
|
||||
self.failUnless(v())
|
||||
self.assertTrue(v())
|
||||
v.set('False')
|
||||
self.failIf(v())
|
||||
self.assertFalse(v())
|
||||
v.set('On')
|
||||
self.failUnless(v())
|
||||
self.assertTrue(v())
|
||||
v.set('Off')
|
||||
self.failIf(v())
|
||||
self.assertFalse(v())
|
||||
v.set('enable')
|
||||
self.failUnless(v())
|
||||
self.assertTrue(v())
|
||||
v.set('disable')
|
||||
self.failIf(v())
|
||||
self.assertFalse(v())
|
||||
v.set('toggle')
|
||||
self.failUnless(v())
|
||||
self.assertTrue(v())
|
||||
v.set('toggle')
|
||||
self.failIf(v())
|
||||
self.assertFalse(v())
|
||||
|
||||
def testInteger(self):
|
||||
v = registry.Integer(1, 'help')
|
||||
@ -179,7 +179,7 @@ class ValuesTestCase(SupyTestCase):
|
||||
v = registry.Regexp(None, 'help')
|
||||
self.assertEqual(v(), None)
|
||||
v.set('m/foo/')
|
||||
self.failUnless(v().match('foo'))
|
||||
self.assertTrue(v().match('foo'))
|
||||
v.set('')
|
||||
self.assertEqual(v(), None)
|
||||
self.assertRaises(registry.InvalidRegistryValue,
|
||||
|
@ -73,12 +73,12 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertNotEqual(f(irc, msg, '$today'), '$today')
|
||||
self.assertNotEqual(f(irc, msg, '$now'), '$now')
|
||||
n = f(irc, msg, '$randnick')
|
||||
self.failUnless(n in irc.state.channels['#foo'].users)
|
||||
self.assertTrue(n in irc.state.channels['#foo'].users)
|
||||
n = f(irc, msg, '$randomnick')
|
||||
self.failUnless(n in irc.state.channels['#foo'].users)
|
||||
self.assertTrue(n in irc.state.channels['#foo'].users)
|
||||
n = f(irc, msg, '$randomnick '*100)
|
||||
L = n.split()
|
||||
self.failIf(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
||||
self.assertFalse(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
||||
c = f(irc, msg, '$channel')
|
||||
self.assertEqual(c, msg.args[0])
|
||||
|
||||
|
@ -76,7 +76,7 @@ class GenTest(SupyTestCase):
|
||||
def testInsensitivePreservingDict(self):
|
||||
ipd = utils.InsensitivePreservingDict
|
||||
d = ipd(dict(Foo=10))
|
||||
self.failUnless(d['foo'] == 10)
|
||||
self.assertTrue(d['foo'] == 10)
|
||||
self.assertEqual(d.keys(), ['Foo'])
|
||||
self.assertEqual(d.get('foo'), 10)
|
||||
self.assertEqual(d.get('Foo'), 10)
|
||||
@ -84,7 +84,7 @@ class GenTest(SupyTestCase):
|
||||
def testFindBinaryInPath(self):
|
||||
if os.name == 'posix':
|
||||
self.assertEqual(None, utils.findBinaryInPath('asdfhjklasdfhjkl'))
|
||||
self.failUnless(utils.findBinaryInPath('sh').endswith('/bin/sh'))
|
||||
self.assertTrue(utils.findBinaryInPath('sh').endswith('/bin/sh'))
|
||||
|
||||
def testExnToString(self):
|
||||
try:
|
||||
@ -124,11 +124,11 @@ class GenTest(SupyTestCase):
|
||||
for (k, v) in self.L:
|
||||
yield (k, v)
|
||||
AL = alist()
|
||||
self.failIf(AL)
|
||||
self.assertFalse(AL)
|
||||
AL[1] = 2
|
||||
AL[2] = 3
|
||||
AL[3] = 4
|
||||
self.failUnless(AL)
|
||||
self.assertTrue(AL)
|
||||
self.assertEqual(list(AL.items()), [(1, 2), (2, 3), (3, 4)])
|
||||
self.assertEqual(list(AL.items()), [(1, 2), (2, 3), (3, 4)])
|
||||
self.assertEqual(list(AL.keys()), [1, 2, 3])
|
||||
@ -271,25 +271,25 @@ class StrTest(SupyTestCase):
|
||||
for s in L:
|
||||
r = utils.str.dqrepr(s)
|
||||
self.assertEqual(s, eval(r), s)
|
||||
self.failUnless(r[0] == '"' and r[-1] == '"', s)
|
||||
self.assertTrue(r[0] == '"' and r[-1] == '"', s)
|
||||
|
||||
def testPerlReToPythonRe(self):
|
||||
f = utils.str.perlReToPythonRe
|
||||
r = f('m/foo/')
|
||||
self.failUnless(r.search('foo'))
|
||||
self.assertTrue(r.search('foo'))
|
||||
r = f('/foo/')
|
||||
self.failUnless(r.search('foo'))
|
||||
self.assertTrue(r.search('foo'))
|
||||
r = f('m/\\//')
|
||||
self.failUnless(r.search('/'))
|
||||
self.assertTrue(r.search('/'))
|
||||
r = f('m/cat/i')
|
||||
self.failUnless(r.search('CAT'))
|
||||
self.assertTrue(r.search('CAT'))
|
||||
self.assertRaises(ValueError, f, 'm/?/')
|
||||
|
||||
def testP2PReDifferentSeparator(self):
|
||||
r = utils.str.perlReToPythonRe('m!foo!')
|
||||
self.failUnless(r.search('foo'))
|
||||
self.assertTrue(r.search('foo'))
|
||||
r = utils.str.perlReToPythonRe('m{cat}')
|
||||
self.failUnless(r.search('cat'))
|
||||
self.assertTrue(r.search('cat'))
|
||||
|
||||
def testPerlReToReplacer(self):
|
||||
PRTR = utils.str.perlReToReplacer
|
||||
@ -350,7 +350,7 @@ class StrTest(SupyTestCase):
|
||||
self.assertEqual(f(L, comma=';', And='or'),
|
||||
'foo; bar; or baz')
|
||||
self.assertEqual(L, original)
|
||||
self.failUnless(f(set(L)))
|
||||
self.assertTrue(f(set(L)))
|
||||
|
||||
def testCommaAndifyRaisesTypeError(self):
|
||||
L = [(2,)]
|
||||
@ -401,8 +401,8 @@ class StrTest(SupyTestCase):
|
||||
def testEllipsisify(self):
|
||||
f = utils.str.ellipsisify
|
||||
self.assertEqual(f('x'*30, 30), 'x'*30)
|
||||
self.failUnless(len(f('x'*35, 30)) <= 30)
|
||||
self.failUnless(f(' '.join(['xxxx']*10), 30)[:-3].endswith('xxxx'))
|
||||
self.assertTrue(len(f('x'*35, 30)) <= 30)
|
||||
self.assertTrue(f(' '.join(['xxxx']*10), 30)[:-3].endswith('xxxx'))
|
||||
|
||||
|
||||
class IterTest(SupyTestCase):
|
||||
@ -443,18 +443,18 @@ class IterTest(SupyTestCase):
|
||||
|
||||
def testAny(self):
|
||||
any = utils.iter.any
|
||||
self.failUnless(any(lambda i: i == 0, range(10)))
|
||||
self.failIf(any(None, range(1)))
|
||||
self.failUnless(any(None, range(2)))
|
||||
self.failIf(any(None, []))
|
||||
self.assertTrue(any(lambda i: i == 0, range(10)))
|
||||
self.assertFalse(any(None, range(1)))
|
||||
self.assertTrue(any(None, range(2)))
|
||||
self.assertFalse(any(None, []))
|
||||
|
||||
def testAll(self):
|
||||
all = utils.iter.all
|
||||
self.failIf(all(lambda i: i == 0, range(10)))
|
||||
self.failIf(all(lambda i: i % 2, range(2)))
|
||||
self.failIf(all(lambda i: i % 2 == 0, [1, 3, 5]))
|
||||
self.failUnless(all(lambda i: i % 2 == 0, [2, 4, 6]))
|
||||
self.failUnless(all(None, ()))
|
||||
self.assertFalse(all(lambda i: i == 0, range(10)))
|
||||
self.assertFalse(all(lambda i: i % 2, range(2)))
|
||||
self.assertFalse(all(lambda i: i % 2 == 0, [1, 3, 5]))
|
||||
self.assertTrue(all(lambda i: i % 2 == 0, [2, 4, 6]))
|
||||
self.assertTrue(all(None, ()))
|
||||
|
||||
def testPartition(self):
|
||||
partition = utils.iter.partition
|
||||
@ -513,9 +513,9 @@ class FileTest(SupyTestCase):
|
||||
|
||||
def testMktemp(self):
|
||||
# This is mostly to test that it actually halts.
|
||||
self.failUnless(utils.file.mktemp())
|
||||
self.failUnless(utils.file.mktemp())
|
||||
self.failUnless(utils.file.mktemp())
|
||||
self.assertTrue(utils.file.mktemp())
|
||||
self.assertTrue(utils.file.mktemp())
|
||||
self.assertTrue(utils.file.mktemp())
|
||||
|
||||
def testSanitizeName(self):
|
||||
self.assertEqual(utils.file.sanitizeName('#foo'), '#foo')
|
||||
@ -525,22 +525,22 @@ class FileTest(SupyTestCase):
|
||||
class NetTest(SupyTestCase):
|
||||
def testEmailRe(self):
|
||||
emailRe = utils.net.emailRe
|
||||
self.failUnless(emailRe.match('jemfinch@supybot.com'))
|
||||
self.assertTrue(emailRe.match('jemfinch@supybot.com'))
|
||||
|
||||
def testIsIP(self):
|
||||
isIP = utils.net.isIP
|
||||
self.failIf(isIP('a.b.c'))
|
||||
self.failIf(isIP('256.0.0.0'))
|
||||
self.failIf(isIP('127.0.0.1 127.0.0.1'))
|
||||
self.failUnless(isIP('0.0.0.0'))
|
||||
self.failUnless(isIP('100.100.100.100'))
|
||||
self.failUnless(isIP('255.255.255.255'))
|
||||
self.assertFalse(isIP('a.b.c'))
|
||||
self.assertFalse(isIP('256.0.0.0'))
|
||||
self.assertFalse(isIP('127.0.0.1 127.0.0.1'))
|
||||
self.assertTrue(isIP('0.0.0.0'))
|
||||
self.assertTrue(isIP('100.100.100.100'))
|
||||
self.assertTrue(isIP('255.255.255.255'))
|
||||
|
||||
def testIsIPV6(self):
|
||||
f = utils.net.isIPV6
|
||||
self.failIf(f('2001:: 2001::'))
|
||||
self.failUnless(f('2001::'))
|
||||
self.failUnless(f('2001:888:0:1::666'))
|
||||
self.assertFalse(f('2001:: 2001::'))
|
||||
self.assertTrue(f('2001::'))
|
||||
self.assertTrue(f('2001:888:0:1::666'))
|
||||
|
||||
class WebTest(SupyTestCase):
|
||||
def testGetDomain(self):
|
||||
@ -550,7 +550,7 @@ class WebTest(SupyTestCase):
|
||||
if network:
|
||||
def testGetUrlWithSize(self):
|
||||
url = 'http://slashdot.org/'
|
||||
self.failUnless(len(utils.web.getUrl(url, 1024)) == 1024)
|
||||
self.assertTrue(len(utils.web.getUrl(url, 1024)) == 1024)
|
||||
|
||||
class FormatTestCase(SupyTestCase):
|
||||
def testNormal(self):
|
||||
@ -594,9 +594,9 @@ class RingBufferTestCase(SupyTestCase):
|
||||
|
||||
def testNonzero(self):
|
||||
b = RingBuffer(3)
|
||||
self.failIf(b)
|
||||
self.assertFalse(b)
|
||||
b.append(1)
|
||||
self.failUnless(b)
|
||||
self.assertTrue(b)
|
||||
|
||||
def testAppend(self):
|
||||
b = RingBuffer(3)
|
||||
@ -616,10 +616,10 @@ class RingBufferTestCase(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
self.failUnless(0 in b)
|
||||
self.failUnless(1 in b)
|
||||
self.failUnless(2 in b)
|
||||
self.failIf(3 in b)
|
||||
self.assertTrue(0 in b)
|
||||
self.assertTrue(1 in b)
|
||||
self.assertTrue(2 in b)
|
||||
self.assertFalse(3 in b)
|
||||
|
||||
def testGetitem(self):
|
||||
L = range(10)
|
||||
@ -674,11 +674,11 @@ class RingBufferTestCase(SupyTestCase):
|
||||
b = RingBuffer(len(L), [0]*len(L))
|
||||
self.assertRaises(ValueError, b.__setitem__, slice(0, 10), [])
|
||||
b[2:4] = L[2:4]
|
||||
self.assertEquals(b[2:4], L[2:4])
|
||||
self.assertEqual(b[2:4], L[2:4])
|
||||
for _ in range(len(b)):
|
||||
b.append(0)
|
||||
b[2:4] = L[2:4]
|
||||
self.assertEquals(b[2:4], L[2:4])
|
||||
self.assertEqual(b[2:4], L[2:4])
|
||||
|
||||
def testExtend(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
@ -708,18 +708,18 @@ class RingBufferTestCase(SupyTestCase):
|
||||
|
||||
def testEq(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
self.failIf(b == list(range(3)))
|
||||
self.assertFalse(b == list(range(3)))
|
||||
b1 = RingBuffer(3)
|
||||
self.failIf(b == b1)
|
||||
self.assertFalse(b == b1)
|
||||
b1.append(0)
|
||||
self.failIf(b == b1)
|
||||
self.assertFalse(b == b1)
|
||||
b1.append(1)
|
||||
self.failIf(b == b1)
|
||||
self.assertFalse(b == b1)
|
||||
b1.append(2)
|
||||
self.failUnless(b == b1)
|
||||
self.assertTrue(b == b1)
|
||||
b = RingBuffer(100, range(10))
|
||||
b1 = RingBuffer(10, range(10))
|
||||
self.failIf(b == b1)
|
||||
self.assertFalse(b == b1)
|
||||
|
||||
def testIter(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
@ -771,11 +771,11 @@ class QueueTest(SupyTestCase):
|
||||
|
||||
def testNonzero(self):
|
||||
q = queue()
|
||||
self.failIf(q, 'queue not zero after initialization')
|
||||
self.assertFalse(q, 'queue not zero after initialization')
|
||||
q.enqueue(1)
|
||||
self.failUnless(q, 'queue zero after adding element')
|
||||
self.assertTrue(q, 'queue zero after adding element')
|
||||
q.dequeue()
|
||||
self.failIf(q, 'queue not zero after dequeue of only element')
|
||||
self.assertFalse(q, 'queue not zero after dequeue of only element')
|
||||
|
||||
def testLen(self):
|
||||
q = queue()
|
||||
@ -796,24 +796,24 @@ class QueueTest(SupyTestCase):
|
||||
def testEq(self):
|
||||
q1 = queue()
|
||||
q2 = queue()
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failUnless(q1 == q2, 'initialized queues not equal')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'initialized queues not equal')
|
||||
q1.enqueue(1)
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
q2.enqueue(1)
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failUnless(q1 == q2, 'queues not equal after identical enqueue')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'queues not equal after identical enqueue')
|
||||
q1.dequeue()
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failIf(q1 == q2, 'queues equal after one dequeue')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertFalse(q1 == q2, 'queues equal after one dequeue')
|
||||
q2.dequeue()
|
||||
self.failUnless(q1 == q2, 'queues not equal after both are dequeued')
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'queues not equal after both are dequeued')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
|
||||
def testInit(self):
|
||||
self.assertEqual(len(queue()), 0, 'queue len not 0 after init')
|
||||
@ -873,17 +873,17 @@ class QueueTest(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
q = queue()
|
||||
self.failIf(1 in q, 'empty queue cannot have elements')
|
||||
self.assertFalse(1 in q, 'empty queue cannot have elements')
|
||||
q.enqueue(1)
|
||||
self.failUnless(1 in q, 'recent enqueued element not in q')
|
||||
self.assertTrue(1 in q, 'recent enqueued element not in q')
|
||||
q.enqueue(2)
|
||||
self.failUnless(1 in q, 'original enqueued element not in q')
|
||||
self.failUnless(2 in q, 'second enqueued element not in q')
|
||||
self.assertTrue(1 in q, 'original enqueued element not in q')
|
||||
self.assertTrue(2 in q, 'second enqueued element not in q')
|
||||
q.dequeue()
|
||||
self.failIf(1 in q, 'dequeued element in q')
|
||||
self.failUnless(2 in q, 'not dequeued element not in q')
|
||||
self.assertFalse(1 in q, 'dequeued element in q')
|
||||
self.assertTrue(2 in q, 'not dequeued element not in q')
|
||||
q.dequeue()
|
||||
self.failIf(2 in q, 'dequeued element in q')
|
||||
self.assertFalse(2 in q, 'dequeued element in q')
|
||||
|
||||
def testIter(self):
|
||||
q1 = queue((1, 2, 3))
|
||||
@ -936,11 +936,11 @@ class SmallQueueTest(SupyTestCase):
|
||||
|
||||
def testNonzero(self):
|
||||
q = queue()
|
||||
self.failIf(q, 'queue not zero after initialization')
|
||||
self.assertFalse(q, 'queue not zero after initialization')
|
||||
q.enqueue(1)
|
||||
self.failUnless(q, 'queue zero after adding element')
|
||||
self.assertTrue(q, 'queue zero after adding element')
|
||||
q.dequeue()
|
||||
self.failIf(q, 'queue not zero after dequeue of only element')
|
||||
self.assertFalse(q, 'queue not zero after dequeue of only element')
|
||||
|
||||
def testLen(self):
|
||||
q = queue()
|
||||
@ -961,24 +961,24 @@ class SmallQueueTest(SupyTestCase):
|
||||
def testEq(self):
|
||||
q1 = queue()
|
||||
q2 = queue()
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failUnless(q1 == q2, 'initialized queues not equal')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'initialized queues not equal')
|
||||
q1.enqueue(1)
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
q2.enqueue(1)
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failUnless(q1 == q2, 'queues not equal after identical enqueue')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'queues not equal after identical enqueue')
|
||||
q1.dequeue()
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.failIf(q1 == q2, 'queues equal after one dequeue')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertFalse(q1 == q2, 'queues equal after one dequeue')
|
||||
q2.dequeue()
|
||||
self.failUnless(q1 == q2, 'queues not equal after both are dequeued')
|
||||
self.failUnless(q1 == q1, 'queue not equal to itself')
|
||||
self.failUnless(q2 == q2, 'queue not equal to itself')
|
||||
self.assertTrue(q1 == q2, 'queues not equal after both are dequeued')
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
|
||||
def testInit(self):
|
||||
self.assertEqual(len(queue()), 0, 'queue len not 0 after init')
|
||||
@ -1038,17 +1038,17 @@ class SmallQueueTest(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
q = queue()
|
||||
self.failIf(1 in q, 'empty queue cannot have elements')
|
||||
self.assertFalse(1 in q, 'empty queue cannot have elements')
|
||||
q.enqueue(1)
|
||||
self.failUnless(1 in q, 'recent enqueued element not in q')
|
||||
self.assertTrue(1 in q, 'recent enqueued element not in q')
|
||||
q.enqueue(2)
|
||||
self.failUnless(1 in q, 'original enqueued element not in q')
|
||||
self.failUnless(2 in q, 'second enqueued element not in q')
|
||||
self.assertTrue(1 in q, 'original enqueued element not in q')
|
||||
self.assertTrue(2 in q, 'second enqueued element not in q')
|
||||
q.dequeue()
|
||||
self.failIf(1 in q, 'dequeued element in q')
|
||||
self.failUnless(2 in q, 'not dequeued element not in q')
|
||||
self.assertFalse(1 in q, 'dequeued element in q')
|
||||
self.assertTrue(2 in q, 'not dequeued element not in q')
|
||||
q.dequeue()
|
||||
self.failIf(2 in q, 'dequeued element in q')
|
||||
self.assertFalse(2 in q, 'dequeued element in q')
|
||||
|
||||
def testIter(self):
|
||||
q1 = queue((1, 2, 3))
|
||||
@ -1089,28 +1089,28 @@ class MaxLengthQueueTestCase(SupyTestCase):
|
||||
class TwoWayDictionaryTestCase(SupyTestCase):
|
||||
def testInit(self):
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
self.failUnless('foo' in d)
|
||||
self.failUnless('bar' in d)
|
||||
self.assertTrue('foo' in d)
|
||||
self.assertTrue('bar' in d)
|
||||
|
||||
d = TwoWayDictionary({1: 2})
|
||||
self.failUnless(1 in d)
|
||||
self.failUnless(2 in d)
|
||||
self.assertTrue(1 in d)
|
||||
self.assertTrue(2 in d)
|
||||
|
||||
def testSetitem(self):
|
||||
d = TwoWayDictionary()
|
||||
d['foo'] = 'bar'
|
||||
self.failUnless('foo' in d)
|
||||
self.failUnless('bar' in d)
|
||||
self.assertTrue('foo' in d)
|
||||
self.assertTrue('bar' in d)
|
||||
|
||||
def testDelitem(self):
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
del d['foo']
|
||||
self.failIf('foo' in d)
|
||||
self.failIf('bar' in d)
|
||||
self.assertFalse('foo' in d)
|
||||
self.assertFalse('bar' in d)
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
del d['bar']
|
||||
self.failIf('bar' in d)
|
||||
self.failIf('foo' in d)
|
||||
self.assertFalse('bar' in d)
|
||||
self.assertFalse('foo' in d)
|
||||
|
||||
|
||||
class TestTimeoutQueue(SupyTestCase):
|
||||
@ -1143,18 +1143,18 @@ class TestTimeoutQueue(SupyTestCase):
|
||||
def testContains(self):
|
||||
q = TimeoutQueue(1)
|
||||
q.enqueue(1)
|
||||
self.failUnless(1 in q)
|
||||
self.failUnless(1 in q) # For some reason, the second one might fail.
|
||||
self.failIf(2 in q)
|
||||
self.assertTrue(1 in q)
|
||||
self.assertTrue(1 in q) # For some reason, the second one might fail.
|
||||
self.assertFalse(2 in q)
|
||||
timeFastForward(1.1)
|
||||
self.failIf(1 in q)
|
||||
self.assertFalse(1 in q)
|
||||
|
||||
def testReset(self):
|
||||
q = TimeoutQueue(10)
|
||||
q.enqueue(1)
|
||||
self.failUnless(1 in q)
|
||||
self.assertTrue(1 in q)
|
||||
q.reset()
|
||||
self.failIf(1 in q)
|
||||
self.assertFalse(1 in q)
|
||||
|
||||
class TestCacheDict(SupyTestCase):
|
||||
def testMaxNeverExceeded(self):
|
||||
@ -1162,22 +1162,22 @@ class TestCacheDict(SupyTestCase):
|
||||
d = CacheDict(10)
|
||||
for i in xrange(max**2):
|
||||
d[i] = i
|
||||
self.failUnless(len(d) <= max)
|
||||
self.failUnless(i in d)
|
||||
self.failUnless(d[i] == i)
|
||||
self.assertTrue(len(d) <= max)
|
||||
self.assertTrue(i in d)
|
||||
self.assertTrue(d[i] == i)
|
||||
|
||||
class TestTruncatableSet(SupyTestCase):
|
||||
def testBasics(self):
|
||||
s = TruncatableSet(['foo', 'bar', 'baz', 'qux'])
|
||||
self.assertEqual(s, set(['foo', 'bar', 'baz', 'qux']))
|
||||
self.failUnless('foo' in s)
|
||||
self.failUnless('bar' in s)
|
||||
self.failIf('quux' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('bar' in s)
|
||||
self.assertFalse('quux' in s)
|
||||
s.discard('baz')
|
||||
self.failUnless('foo' in s)
|
||||
self.failIf('baz' in s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertFalse('baz' in s)
|
||||
s.add('quux')
|
||||
self.failUnless('quux' in s)
|
||||
self.assertTrue('quux' in s)
|
||||
|
||||
def testTruncate(self):
|
||||
s = TruncatableSet(['foo', 'bar'])
|
||||
|
Loading…
Reference in New Issue
Block a user