mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-26 04:39:26 +01:00
parent
fd248dc521
commit
314fad36eb
@ -111,7 +111,7 @@ class AliasTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('foobar', 'sbbone')
|
||||
self.assertRaises(Alias.AliasError, cb.removeAlias, 'foobar')
|
||||
cb.removeAlias('foobar', evenIfLocked=True)
|
||||
self.assertFalse('foobar' in cb.aliases)
|
||||
self.assertNotIn('foobar', cb.aliases)
|
||||
self.assertError('foobar')
|
||||
|
||||
self.assertRegexp('alias add abc\x07 ignore', 'Error.*Invalid')
|
||||
|
@ -39,7 +39,7 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
||||
|
||||
with conf.supybot.plugins.Anonymous.requireRegistration.context(False):
|
||||
m = self.assertNotError('anonymous say %s foo!' % self.channel)
|
||||
self.assertTrue(m.args[1] == 'foo!')
|
||||
self.assertEqual(m.args[1], 'foo!')
|
||||
|
||||
def testTell(self):
|
||||
self.assertError('anonymous tell %s I love you!' % self.nick)
|
||||
@ -48,7 +48,7 @@ class AnonymousTestCase(ChannelPluginTestCase):
|
||||
self.assertError('anonymous tell %s foo!' % self.channel)
|
||||
with conf.supybot.plugins.Anonymous.allowPrivateTarget.context(True):
|
||||
m = self.assertNotError('anonymous tell %s foo!' % self.nick)
|
||||
self.assertTrue(m.args[1] == 'foo!')
|
||||
self.assertEqual(m.args[1], 'foo!')
|
||||
|
||||
def testAction(self):
|
||||
m = self.assertError('anonymous do %s loves you!' % self.channel)
|
||||
|
@ -43,8 +43,11 @@ class GamesTestCase(ChannelPluginTestCase):
|
||||
'Got a msg without bang|click|spin: %r' % m)
|
||||
elif m.command == 'KICK':
|
||||
sawKick = True
|
||||
self.assertTrue('bang' in m.args[2].lower(),
|
||||
'Got a KICK without bang in it.')
|
||||
self.assertIn(
|
||||
'bang',
|
||||
m.args[2].lower(),
|
||||
'Got a KICK without bang in it.'
|
||||
)
|
||||
else:
|
||||
self.fail('Got something other than a kick or a privmsg.')
|
||||
self.assertTrue(sawKick, 'Didn\'t get a kick in %s iterations!' % i)
|
||||
|
@ -44,7 +44,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.assertFalse(m is not None)
|
||||
self.assertIsNone(m)
|
||||
conf.supybot.plugins.Limiter.maximumExcess.setValue(7)
|
||||
self.irc.feedMsg(ircmsgs.part('#foo', prefix='bar!root@host'))
|
||||
m = self.irc.takeMsg()
|
||||
|
@ -130,7 +130,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
def testHelpIncludeFullCommandName(self):
|
||||
self.assertHelp('help channel capability add')
|
||||
m = self.getMsg('help channel capability add')
|
||||
self.assertTrue('channel capability add' in m.args[1])
|
||||
self.assertIn('channel capability add', m.args[1])
|
||||
|
||||
def testHelpDoesAmbiguityWithDefaultPlugins(self):
|
||||
m = self.getMsg('help list') # Misc.list and User.list.
|
||||
@ -189,12 +189,12 @@ 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.assertTrue('let you do' in m.args[1])
|
||||
self.assertIn('let you do', m.args[1])
|
||||
m = self.getMsg('tell #foo [plugin tell]')
|
||||
self.assertTrue('No need for' in m.args[1])
|
||||
self.assertIn('No need for', m.args[1])
|
||||
m = self.getMsg('tell me you love me')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.args[0] == self.nick)
|
||||
self.assertEqual(m.args[0], self.nick)
|
||||
|
||||
def testNoNestedTell(self):
|
||||
self.assertRegexp('echo [tell %s foo]' % self.nick, 'nested')
|
||||
@ -271,7 +271,7 @@ class MiscTestCase(ChannelPluginTestCase):
|
||||
self.assertResponse('more',
|
||||
'abc '*112 + ' \x02(2 more messages)\x02')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertIsNot(m, None)
|
||||
self.assertIsNotNone(m)
|
||||
self.assertEqual(
|
||||
m.args[1],
|
||||
'abc '*112 + ' \x02(1 more message)\x02')
|
||||
|
@ -54,8 +54,11 @@ class OptionListTestCase(SupyTestCase):
|
||||
while max and L:
|
||||
max -= 1
|
||||
option = plugin.pickOptions(s)
|
||||
self.assertTrue(option in original,
|
||||
'Option %s not in %s' % (option, original))
|
||||
self.assertIn(
|
||||
option,
|
||||
original,
|
||||
'Option %s not in %s' % (option, original)
|
||||
)
|
||||
if option in L:
|
||||
L.remove(option)
|
||||
self.assertFalse(L, 'Some options never seen: %s' % L)
|
||||
|
@ -414,7 +414,7 @@ class RSSTestCase(ChannelPluginTestCase):
|
||||
timeFastForward(1.1)
|
||||
self.assertNotError('rss %s' % url)
|
||||
m = self.assertNotError('rss %s 2' % url)
|
||||
self.assertTrue(m.args[1].count(' | ') == 1)
|
||||
self.assertEqual(m.args[1].count(' | '), 1)
|
||||
|
||||
def testRssAdd(self):
|
||||
timeFastForward(1.1)
|
||||
|
@ -63,6 +63,6 @@ class ReplyNonChannelTestCase(PluginTestCase):
|
||||
self.prefix = 'something!else@somewhere.else'
|
||||
self.nick = 'something'
|
||||
m = self.assertAction('action foo', 'foo')
|
||||
self.assertFalse(m.args[0] == self.irc.nick)
|
||||
self.assertNotEqual(m.args[0], self.irc.nick)
|
||||
|
||||
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
|
||||
|
@ -86,7 +86,7 @@ class ChannelDBTestCase(ChannelPluginTestCase):
|
||||
self.assertError('seen *')
|
||||
self.assertNotError('seen %s' % self.nick)
|
||||
m = self.assertNotError('seen %s' % self.nick.upper())
|
||||
self.assertTrue(self.nick.upper() in m.args[1])
|
||||
self.assertIn(self.nick.upper(), m.args[1])
|
||||
self.assertRegexp('seen user %s' % self.nick,
|
||||
'^%s was last seen' % self.nick)
|
||||
self.assertNotError('config plugins.Seen.minimumNonWildcard 0')
|
||||
|
@ -50,12 +50,12 @@ class ServicesTestCase(PluginTestCase):
|
||||
try:
|
||||
self.assertNotError('services password %s baz' % self.nick)
|
||||
m = self.assertNotError('services identify')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify baz')
|
||||
self.assertEqual(m.args[0], 'NickServ')
|
||||
self.assertEqual(m.args[1].lower(), 'identify baz')
|
||||
self.assertNotError('services password %s biff' % self.nick)
|
||||
m = self.assertNotError('services identify')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify biff')
|
||||
self.assertEqual(m.args[0], 'NickServ')
|
||||
self.assertEqual(m.args[1].lower(), 'identify biff')
|
||||
finally:
|
||||
self.assertNotError('services password %s ""' % self.nick)
|
||||
|
||||
@ -84,8 +84,8 @@ class ServicesTestCase(PluginTestCase):
|
||||
'Global: bar; test: bar2')
|
||||
|
||||
m = self.assertNotError('services identify')
|
||||
self.assertTrue(m.args[0] == 'NickServ')
|
||||
self.assertTrue(m.args[1].lower() == 'identify bar2')
|
||||
self.assertEqual(m.args[0], 'NickServ')
|
||||
self.assertEqual(m.args[1].lower(), 'identify bar2')
|
||||
finally:
|
||||
self.assertNotError('services password %s ""' % self.nick)
|
||||
|
||||
|
@ -41,8 +41,8 @@ class StatusTestCase(PluginTestCase):
|
||||
|
||||
def testCpu(self):
|
||||
m = self.assertNotError('status cpu')
|
||||
self.assertFalse('kB kB' in m.args[1])
|
||||
self.assertFalse('None' in m.args[1], 'None in cpu output: %r.' % m)
|
||||
self.assertNotIn('kB kB', m.args[1])
|
||||
self.assertNotIn('None', m.args[1], 'None in cpu output: %r.' % m)
|
||||
for s in ['linux', 'freebsd', 'openbsd', 'netbsd', 'darwin']:
|
||||
if sys.platform.startswith(s):
|
||||
self.assertTrue('B' in m.args[1] or 'KB' in m.args[1] or
|
||||
|
@ -129,7 +129,7 @@ class TopicTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.plugins.Topic.separator.setValue(' <==> ')
|
||||
_ = self.getMsg('topic add foo')
|
||||
m = self.getMsg('topic add bar')
|
||||
self.assertTrue('<==>' in m.args[1])
|
||||
self.assertIn('<==>', m.args[1])
|
||||
finally:
|
||||
conf.supybot.plugins.Topic.separator.setValue(original)
|
||||
|
||||
|
@ -104,7 +104,7 @@ class UserTestCase(PluginTestCase):
|
||||
self.assertResponse('hostmask', self.prefix)
|
||||
self.assertError('@hostmask asdf')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertFalse(m is not None, m)
|
||||
self.assertIsNone(m, m)
|
||||
|
||||
def testRegisterPasswordLength(self):
|
||||
self.assertRegexp('register foo aa', 'at least 3 characters long.')
|
||||
@ -131,7 +131,7 @@ class UserTestCase(PluginTestCase):
|
||||
try:
|
||||
self.assertError('unregister foo')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertFalse(m is not None, m)
|
||||
self.assertIsNone(m, m)
|
||||
self.assertTrue(ircdb.users.getUserId('foo'))
|
||||
finally:
|
||||
conf.supybot.databases.users.allowUnregistration.setValue(orig)
|
||||
|
@ -417,14 +417,14 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
def testReplyWithNickPrefix(self):
|
||||
self.feedMsg('@len foo')
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m is not None, 'm: %r' % m)
|
||||
self.assertIsNotNone(m, '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.assertTrue(m is not None)
|
||||
self.assertIsNotNone(m)
|
||||
self.assertFalse(m.args[1].startswith(self.nick))
|
||||
finally:
|
||||
conf.supybot.reply.withNickPrefix.setValue(original)
|
||||
@ -448,7 +448,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.reply.error.withNotice.setValue(True)
|
||||
m = self.getMsg("eval irc.error('foo')")
|
||||
self.assertTrue(m, 'No message returned.')
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertEqual(m.command, 'NOTICE')
|
||||
finally:
|
||||
conf.supybot.reply.error.withNotice.setValue(original)
|
||||
|
||||
@ -1112,10 +1112,10 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
self.irc.addCallback(self.WithPrivateNotice(self.irc))
|
||||
# Check normal behavior.
|
||||
m = self.assertNotError('normal')
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertNotEqual(m.command, 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertNotEqual(m.command, 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
# Check abnormal behavior.
|
||||
originalInPrivate = conf.supybot.reply.inPrivate()
|
||||
@ -1124,10 +1124,10 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
conf.supybot.reply.inPrivate.setValue(True)
|
||||
conf.supybot.reply.withNotice.setValue(True)
|
||||
m = self.assertNotError('normal')
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertEqual(m.command, 'NOTICE')
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('explicit')
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertNotEqual(m.command, 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.inPrivate.setValue(originalInPrivate)
|
||||
@ -1136,10 +1136,10 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(True)
|
||||
m = self.assertNotError('implicit')
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertEqual(m.command, 'NOTICE')
|
||||
self.assertFalse(ircutils.isChannel(m.args[0]))
|
||||
m = self.assertNotError('normal')
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertNotEqual(m.command, 'NOTICE')
|
||||
self.assertTrue(ircutils.isChannel(m.args[0]))
|
||||
finally:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(orig)
|
||||
@ -1149,10 +1149,10 @@ class WithPrivateNoticeTestCase(ChannelPluginTestCase):
|
||||
try:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(True)
|
||||
m = self.assertNotError("eval irc.reply('y',to='x',private=True)")
|
||||
self.assertTrue(m.command == 'NOTICE')
|
||||
self.assertEqual(m.command, 'NOTICE')
|
||||
m = self.getMsg(' ')
|
||||
m = self.assertNotError("eval irc.reply('y',to='#x',private=True)")
|
||||
self.assertFalse(m.command == 'NOTICE')
|
||||
self.assertNotEqual(m.command, 'NOTICE')
|
||||
finally:
|
||||
conf.supybot.reply.withNoticeWhenPrivate.setValue(original)
|
||||
|
||||
@ -1164,28 +1164,28 @@ class ProxyTestCase(SupyTestCase):
|
||||
irc = irclib.Irc('test')
|
||||
proxy = callbacks.SimpleProxy(irc, msg)
|
||||
# First one way...
|
||||
self.assertFalse(proxy != irc)
|
||||
self.assertTrue(proxy == irc)
|
||||
self.assertEqual(proxy, irc)
|
||||
self.assertEqual(proxy, irc)
|
||||
self.assertEqual(hash(proxy), hash(irc))
|
||||
# Then the other!
|
||||
self.assertFalse(irc != proxy)
|
||||
self.assertTrue(irc == proxy)
|
||||
self.assertEqual(irc, proxy)
|
||||
self.assertEqual(irc, proxy)
|
||||
self.assertEqual(hash(irc), hash(proxy))
|
||||
|
||||
# And now dictionaries...
|
||||
d = {}
|
||||
d[irc] = 'foo'
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'foo')
|
||||
self.assertTrue(d[proxy] == 'foo')
|
||||
self.assertEqual(len(d), 1)
|
||||
self.assertEqual(d[irc], 'foo')
|
||||
self.assertEqual(d[proxy], 'foo')
|
||||
d[proxy] = 'bar'
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'bar')
|
||||
self.assertTrue(d[proxy] == 'bar')
|
||||
self.assertEqual(len(d), 1)
|
||||
self.assertEqual(d[irc], 'bar')
|
||||
self.assertEqual(d[proxy], 'bar')
|
||||
d[irc] = 'foo'
|
||||
self.assertTrue(len(d) == 1)
|
||||
self.assertTrue(d[irc] == 'foo')
|
||||
self.assertTrue(d[proxy] == 'foo')
|
||||
self.assertEqual(len(d), 1)
|
||||
self.assertEqual(d[irc], 'foo')
|
||||
self.assertEqual(d[proxy], 'foo')
|
||||
|
||||
|
||||
|
||||
|
@ -122,17 +122,17 @@ class CapabilitySetTestCase(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
s = ircdb.CapabilitySet()
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('-foo' in s)
|
||||
self.assertNotIn('foo', s)
|
||||
self.assertNotIn('-foo', s)
|
||||
s.add('foo')
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('-foo', s)
|
||||
s.remove('foo')
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('-foo' in s)
|
||||
self.assertNotIn('foo', s)
|
||||
self.assertNotIn('-foo', s)
|
||||
s.add('-foo')
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('-foo', s)
|
||||
|
||||
def testCheck(self):
|
||||
s = ircdb.CapabilitySet()
|
||||
@ -170,8 +170,8 @@ class UserCapabilitySetTestCase(SupyTestCase):
|
||||
|
||||
def testOwnerIsAlwaysPresent(self):
|
||||
d = ircdb.UserCapabilitySet()
|
||||
self.assertTrue('owner' in d)
|
||||
self.assertTrue('-owner' in d)
|
||||
self.assertIn('owner', d)
|
||||
self.assertIn('-owner', d)
|
||||
self.assertFalse(d.check('owner'))
|
||||
d.add('owner')
|
||||
self.assertTrue(d.check('owner'))
|
||||
@ -187,8 +187,8 @@ class UserCapabilitySetTestCase(SupyTestCase):
|
||||
def testOwner(self):
|
||||
s = ircdb.UserCapabilitySet()
|
||||
s.add('owner')
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('-foo' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('-foo', s)
|
||||
self.assertTrue(s.check('owner'))
|
||||
self.assertFalse(s.check('-owner'))
|
||||
self.assertFalse(s.check('-foo'))
|
||||
@ -265,7 +265,7 @@ class IrcUserTestCase(IrcdbTestCase):
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
u.addAuth('foo!bar@baz')
|
||||
self.assertTrue(u.checkHostmask('foo!bar@baz'))
|
||||
self.assertTrue(len(u.auth) == 1)
|
||||
self.assertEqual(len(u.auth), 1)
|
||||
u.addAuth('boo!far@fizz')
|
||||
self.assertTrue(u.checkHostmask('boo!far@fizz'))
|
||||
timeFastForward(2.1)
|
||||
|
@ -52,21 +52,21 @@ class CapNegMixin:
|
||||
|
||||
def startCapNegociation(self, caps='sasl'):
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertEqual(m.command, 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertEqual(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.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'sasl')
|
||||
|
||||
@ -75,7 +75,7 @@ class CapNegMixin:
|
||||
|
||||
def endCapNegociation(self):
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('END',), m)
|
||||
|
||||
|
||||
@ -204,13 +204,13 @@ class IrcMsgQueueTestCase(SupyTestCase):
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.msg)
|
||||
q.enqueue(self.msg)
|
||||
self.assertTrue(self.msg in q)
|
||||
self.assertIn(self.msg, q)
|
||||
q.dequeue()
|
||||
self.assertTrue(self.msg in q)
|
||||
self.assertIn(self.msg, q)
|
||||
q.dequeue()
|
||||
self.assertTrue(self.msg in q)
|
||||
self.assertIn(self.msg, q)
|
||||
q.dequeue()
|
||||
self.assertFalse(self.msg in q)
|
||||
self.assertNotIn(self.msg, q)
|
||||
|
||||
def testRepr(self):
|
||||
q = irclib.IrcMsgQueue()
|
||||
@ -313,39 +313,39 @@ class ChannelStateTestCase(SupyTestCase):
|
||||
c1 = pickle.loads(pickle.dumps(c))
|
||||
self.assertEqual(c, c1)
|
||||
c.removeUser('jemfinch')
|
||||
self.assertFalse('jemfinch' in c.users)
|
||||
self.assertTrue('jemfinch' in c1.users)
|
||||
self.assertNotIn('jemfinch', c.users)
|
||||
self.assertIn('jemfinch', c1.users)
|
||||
|
||||
def testCopy(self):
|
||||
c = irclib.ChannelState()
|
||||
c.addUser('jemfinch')
|
||||
c1 = copy.deepcopy(c)
|
||||
c.removeUser('jemfinch')
|
||||
self.assertFalse('jemfinch' in c.users)
|
||||
self.assertTrue('jemfinch' in c1.users)
|
||||
self.assertNotIn('jemfinch', c.users)
|
||||
self.assertIn('jemfinch', c1.users)
|
||||
|
||||
def testAddUser(self):
|
||||
c = irclib.ChannelState()
|
||||
c.addUser('foo')
|
||||
self.assertTrue('foo' in c.users)
|
||||
self.assertFalse('foo' in c.ops)
|
||||
self.assertFalse('foo' in c.voices)
|
||||
self.assertFalse('foo' in c.halfops)
|
||||
self.assertIn('foo', c.users)
|
||||
self.assertNotIn('foo', c.ops)
|
||||
self.assertNotIn('foo', c.voices)
|
||||
self.assertNotIn('foo', c.halfops)
|
||||
c.addUser('+bar')
|
||||
self.assertTrue('bar' in c.users)
|
||||
self.assertTrue('bar' in c.voices)
|
||||
self.assertFalse('bar' in c.ops)
|
||||
self.assertFalse('bar' in c.halfops)
|
||||
self.assertIn('bar', c.users)
|
||||
self.assertIn('bar', c.voices)
|
||||
self.assertNotIn('bar', c.ops)
|
||||
self.assertNotIn('bar', c.halfops)
|
||||
c.addUser('%baz')
|
||||
self.assertTrue('baz' in c.users)
|
||||
self.assertTrue('baz' in c.halfops)
|
||||
self.assertFalse('baz' in c.voices)
|
||||
self.assertFalse('baz' in c.ops)
|
||||
self.assertIn('baz', c.users)
|
||||
self.assertIn('baz', c.halfops)
|
||||
self.assertNotIn('baz', c.voices)
|
||||
self.assertNotIn('baz', c.ops)
|
||||
c.addUser('@quuz')
|
||||
self.assertTrue('quuz' in c.users)
|
||||
self.assertTrue('quuz' in c.ops)
|
||||
self.assertFalse('quuz' in c.halfops)
|
||||
self.assertFalse('quuz' in c.voices)
|
||||
self.assertIn('quuz', c.users)
|
||||
self.assertIn('quuz', c.ops)
|
||||
self.assertNotIn('quuz', c.halfops)
|
||||
self.assertNotIn('quuz', c.voices)
|
||||
|
||||
|
||||
class IrcStateTestCase(SupyTestCase):
|
||||
@ -362,7 +362,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.assertFalse('#foo' in st.channels)
|
||||
self.assertNotIn('#foo', st.channels)
|
||||
|
||||
def testAddMsgRemovesOpsProperly(self):
|
||||
st = irclib.IrcState()
|
||||
@ -370,18 +370,18 @@ class IrcStateTestCase(SupyTestCase):
|
||||
st.channels['#foo'].ops.add('bar')
|
||||
m = ircmsgs.mode('#foo', ('-o', 'bar'))
|
||||
st.addMsg(self.irc, m)
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
self.assertNotIn('bar', st.channels['#foo'].ops)
|
||||
|
||||
def testNickChangesChangeChannelUsers(self):
|
||||
st = irclib.IrcState()
|
||||
st.channels['#foo'] = irclib.ChannelState()
|
||||
st.channels['#foo'].addUser('@bar')
|
||||
self.assertTrue('bar' in st.channels['#foo'].users)
|
||||
self.assertIn('bar', st.channels['#foo'].users)
|
||||
self.assertTrue(st.channels['#foo'].isOp('bar'))
|
||||
st.addMsg(self.irc, ircmsgs.IrcMsg(':bar!asfd@asdf.com NICK baz'))
|
||||
self.assertFalse('bar' in st.channels['#foo'].users)
|
||||
self.assertNotIn('bar', st.channels['#foo'].users)
|
||||
self.assertFalse(st.channels['#foo'].isOp('bar'))
|
||||
self.assertTrue('baz' in st.channels['#foo'].users)
|
||||
self.assertIn('baz', st.channels['#foo'].users)
|
||||
self.assertTrue(st.channels['#foo'].isOp('baz'))
|
||||
|
||||
def testHistory(self):
|
||||
@ -478,19 +478,19 @@ class IrcStateTestCase(SupyTestCase):
|
||||
state = irclib.IrcState()
|
||||
stateCopy = state.copy()
|
||||
state.channels['#foo'] = None
|
||||
self.assertFalse('#foo' in stateCopy.channels)
|
||||
self.assertNotIn('#foo', stateCopy.channels)
|
||||
|
||||
def testJoin(self):
|
||||
st = irclib.IrcState()
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix))
|
||||
self.assertTrue('#foo' in st.channels)
|
||||
self.assertTrue(self.irc.nick in st.channels['#foo'].users)
|
||||
self.assertIn('#foo', st.channels)
|
||||
self.assertIn(self.irc.nick, st.channels['#foo'].users)
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix='foo!bar@baz'))
|
||||
self.assertTrue('foo' in st.channels['#foo'].users)
|
||||
self.assertIn('foo', st.channels['#foo'].users)
|
||||
st2 = st.copy()
|
||||
st.addMsg(self.irc, ircmsgs.quit(prefix='foo!bar@baz'))
|
||||
self.assertFalse('foo' in st.channels['#foo'].users)
|
||||
self.assertTrue('foo' in st2.channels['#foo'].users)
|
||||
self.assertNotIn('foo', st.channels['#foo'].users)
|
||||
self.assertIn('foo', st2.channels['#foo'].users)
|
||||
|
||||
|
||||
def testEq(self):
|
||||
@ -508,23 +508,23 @@ class IrcStateTestCase(SupyTestCase):
|
||||
def testHandlesModes(self):
|
||||
st = irclib.IrcState()
|
||||
st.addMsg(self.irc, ircmsgs.join('#foo', prefix=self.irc.prefix))
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
self.assertNotIn('bar', st.channels['#foo'].ops)
|
||||
st.addMsg(self.irc, ircmsgs.op('#foo', 'bar'))
|
||||
self.assertTrue('bar' in st.channels['#foo'].ops)
|
||||
self.assertIn('bar', st.channels['#foo'].ops)
|
||||
st.addMsg(self.irc, ircmsgs.deop('#foo', 'bar'))
|
||||
self.assertFalse('bar' in st.channels['#foo'].ops)
|
||||
self.assertNotIn('bar', st.channels['#foo'].ops)
|
||||
|
||||
self.assertFalse('bar' in st.channels['#foo'].voices)
|
||||
self.assertNotIn('bar', st.channels['#foo'].voices)
|
||||
st.addMsg(self.irc, ircmsgs.voice('#foo', 'bar'))
|
||||
self.assertTrue('bar' in st.channels['#foo'].voices)
|
||||
self.assertIn('bar', st.channels['#foo'].voices)
|
||||
st.addMsg(self.irc, ircmsgs.devoice('#foo', 'bar'))
|
||||
self.assertFalse('bar' in st.channels['#foo'].voices)
|
||||
self.assertNotIn('bar', st.channels['#foo'].voices)
|
||||
|
||||
self.assertFalse('bar' in st.channels['#foo'].halfops)
|
||||
self.assertNotIn('bar', st.channels['#foo'].halfops)
|
||||
st.addMsg(self.irc, ircmsgs.halfop('#foo', 'bar'))
|
||||
self.assertTrue('bar' in st.channels['#foo'].halfops)
|
||||
self.assertIn('bar', st.channels['#foo'].halfops)
|
||||
st.addMsg(self.irc, ircmsgs.dehalfop('#foo', 'bar'))
|
||||
self.assertFalse('bar' in st.channels['#foo'].halfops)
|
||||
self.assertNotIn('bar', st.channels['#foo'].halfops)
|
||||
|
||||
def testDoModeOnlyChannels(self):
|
||||
st = irclib.IrcState()
|
||||
@ -572,14 +572,14 @@ class IrcCapsTestCase(SupyTestCase, CapNegMixin):
|
||||
self.irc = irclib.Irc('test')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertEqual(m.command, 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertEqual(m.command, 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
self.irc.REQUEST_CAPABILITIES = set(['a'*400, 'b'*400])
|
||||
caps = ' '.join(self.irc.REQUEST_CAPABILITIES)
|
||||
@ -589,12 +589,12 @@ class IrcCapsTestCase(SupyTestCase, CapNegMixin):
|
||||
args=('*', 'LS', 'b'*400)))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(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.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'b'*400)
|
||||
|
||||
@ -602,20 +602,20 @@ class IrcCapsTestCase(SupyTestCase, CapNegMixin):
|
||||
self.irc = irclib.Irc('test')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertEqual(m.command, 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertEqual(m.command, 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||
args=('*', 'LS', 'account-notify echo-message')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'account-notify')
|
||||
|
||||
@ -626,21 +626,21 @@ class IrcCapsTestCase(SupyTestCase, CapNegMixin):
|
||||
args=('*', 'ACK', 'account-notify')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('END',), m)
|
||||
|
||||
def testEchomessageLabeledresponseGrouped(self):
|
||||
self.irc = irclib.Irc('test')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertEqual(m.command, 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertEqual(m.command, 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
self.irc.REQUEST_CAPABILITIES = set([
|
||||
'account-notify', 'a'*490, 'echo-message', 'labeled-response'])
|
||||
@ -649,17 +649,17 @@ class IrcCapsTestCase(SupyTestCase, CapNegMixin):
|
||||
'account-notify ' + 'a'*490 + ' echo-message labeled-response')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'echo-message labeled-response')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'a'*490)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args[0], 'REQ', m)
|
||||
self.assertEqual(m.args[1], 'account-notify')
|
||||
|
||||
@ -836,14 +836,14 @@ class IrcTestCase(SupyTestCase):
|
||||
#self.assertTrue(m.command == 'PASS', 'Expected PASS, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertTrue(m.args == ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('LS', '302'), 'Expected CAP LS 302, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'NICK', 'Expected NICK, got %r.' % m)
|
||||
self.assertEqual(m.command, 'NICK', 'Expected NICK, got %r.' % m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'USER', 'Expected USER, got %r.' % m)
|
||||
self.assertEqual(m.command, 'USER', 'Expected USER, got %r.' % m)
|
||||
|
||||
# TODO
|
||||
self.irc.feedMsg(ircmsgs.IrcMsg(command='CAP',
|
||||
@ -852,7 +852,7 @@ class IrcTestCase(SupyTestCase):
|
||||
args=('*', 'LS', 'extended-join')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(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.
|
||||
@ -862,11 +862,11 @@ class IrcTestCase(SupyTestCase):
|
||||
args=('*', 'ACK', 'account-tag multi-prefix extended-join')))
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.command, 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(m.args, ('END',), m)
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m is None, m)
|
||||
self.assertIsNone(m, m)
|
||||
|
||||
def testPingResponse(self):
|
||||
self.irc.feedMsg(ircmsgs.ping('123'))
|
||||
@ -890,9 +890,9 @@ class IrcTestCase(SupyTestCase):
|
||||
self.irc.queueMsg(ircmsgs.IrcMsg('NOTICE #foo bar'))
|
||||
self.irc.sendMsg(ircmsgs.IrcMsg('PRIVMSG #foo yeah!'))
|
||||
msg = self.irc.takeMsg()
|
||||
self.assertTrue(msg.command == 'PRIVMSG')
|
||||
self.assertEqual(msg.command, 'PRIVMSG')
|
||||
msg = self.irc.takeMsg()
|
||||
self.assertTrue(msg.command == 'NOTICE')
|
||||
self.assertEqual(msg.command, 'NOTICE')
|
||||
|
||||
def testNoMsgLongerThan512(self):
|
||||
self.irc.queueMsg(ircmsgs.privmsg('whocares', 'x'*1000))
|
||||
@ -1542,7 +1542,7 @@ class SaslTestCase(SupyTestCase, CapNegMixin):
|
||||
conf.supybot.networks.test.sasl.password.setValue('')
|
||||
|
||||
m = self.irc.takeMsg()
|
||||
self.assertTrue(m.command == 'CAP', 'Expected CAP, got %r.' % m)
|
||||
self.assertEqual(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',
|
||||
|
@ -70,7 +70,7 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
|
||||
def testNe(self):
|
||||
for msg in msgs:
|
||||
self.assertFalse(msg != msg)
|
||||
self.assertEqual(msg, msg)
|
||||
|
||||
## def testImmutability(self):
|
||||
## s = 'something else'
|
||||
@ -99,7 +99,7 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
prefix='foo!bar@baz')
|
||||
m = ircmsgs.IrcMsg(prefix='foo!bar@baz', args=('foo', 'bar'),
|
||||
command='CMD')
|
||||
self.assertIs(m.time, None)
|
||||
self.assertIsNone(m.time)
|
||||
m.time = 24
|
||||
self.assertEqual(ircmsgs.IrcMsg(msg=m).time, 24)
|
||||
|
||||
|
@ -236,53 +236,53 @@ class FunctionsTestCase(SupyTestCase):
|
||||
s = ('foo bar baz qux ' * 100)[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 10)
|
||||
self.assertTrue(max(map(pred, r)) <= 10)
|
||||
self.assertLessEqual(max(map(pred, r)), 10)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertLessEqual(max(map(pred, r)), 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = (''.join([chr(0x1f527), chr(0x1f527), chr(0x1f527), ' ']) * 100)\
|
||||
[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 20)
|
||||
self.assertTrue(max(map(pred, r)) <= 20, (max(map(pred, r)), repr(r)))
|
||||
self.assertLessEqual(max(map(pred, r)), 20, (max(map(pred, r)), repr(r)))
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertLessEqual(max(map(pred, r)), 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = ('foobarbazqux ' * 100)[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 10)
|
||||
self.assertTrue(max(map(pred, r)) <= 10)
|
||||
self.assertLessEqual(max(map(pred, r)), 10)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertLessEqual(max(map(pred, r)), 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = ('foobarbazqux' * 100)[0:-1]
|
||||
|
||||
r = ircutils.wrap(s, 10)
|
||||
self.assertTrue(max(map(pred, r)) <= 10)
|
||||
self.assertLessEqual(max(map(pred, r)), 10)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
r = ircutils.wrap(s, 100)
|
||||
self.assertTrue(max(map(pred, r)) <= 100)
|
||||
self.assertLessEqual(max(map(pred, r)), 100)
|
||||
self.assertEqual(''.join(r), s)
|
||||
|
||||
s = chr(233)*500
|
||||
r = ircutils.wrap(s, 500)
|
||||
self.assertTrue(max(map(pred, r)) <= 500)
|
||||
self.assertLessEqual(max(map(pred, r)), 500)
|
||||
r = ircutils.wrap(s, 139)
|
||||
self.assertTrue(max(map(pred, r)) <= 139)
|
||||
self.assertLessEqual(max(map(pred, r)), 139)
|
||||
|
||||
s = '\x02\x16 barbazqux' + ('foobarbazqux ' * 20)[0:-1]
|
||||
r = ircutils.wrap(s, 91)
|
||||
self.assertTrue(max(map(pred, r)) <= 91)
|
||||
self.assertLessEqual(max(map(pred, r)), 91)
|
||||
|
||||
def testSafeArgument(self):
|
||||
s = 'I have been running for 9 seconds'
|
||||
@ -453,9 +453,9 @@ class IrcDictTestCase(SupyTestCase):
|
||||
def testContains(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['#FOO'] = None
|
||||
self.assertTrue('#foo' in d)
|
||||
self.assertIn('#foo', d)
|
||||
d['#fOOBAR[]'] = None
|
||||
self.assertTrue('#foobar{}' in d)
|
||||
self.assertIn('#foobar{}', d)
|
||||
|
||||
def testGetSetItem(self):
|
||||
d = ircutils.IrcDict()
|
||||
@ -467,8 +467,8 @@ class IrcDictTestCase(SupyTestCase):
|
||||
def testCopyable(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['foo'] = 'bar'
|
||||
self.assertTrue(d == copy.copy(d))
|
||||
self.assertTrue(d == copy.deepcopy(d))
|
||||
self.assertEqual(d, copy.copy(d))
|
||||
self.assertEqual(d, copy.deepcopy(d))
|
||||
|
||||
|
||||
class IrcSetTestCase(SupyTestCase):
|
||||
@ -476,30 +476,30 @@ class IrcSetTestCase(SupyTestCase):
|
||||
s = ircutils.IrcSet()
|
||||
s.add('foo')
|
||||
s.add('bar')
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('FOO' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('FOO', s)
|
||||
s.discard('alfkj')
|
||||
s.remove('FOo')
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('FOo' in s)
|
||||
self.assertNotIn('foo', s)
|
||||
self.assertNotIn('FOo', s)
|
||||
|
||||
def testCopy(self):
|
||||
s = ircutils.IrcSet()
|
||||
s.add('foo')
|
||||
s.add('bar')
|
||||
s1 = copy.deepcopy(s)
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('FOO' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('FOO', s)
|
||||
s.discard('alfkj')
|
||||
s.remove('FOo')
|
||||
self.assertFalse('foo' in s)
|
||||
self.assertFalse('FOo' in s)
|
||||
self.assertTrue('foo' in s1)
|
||||
self.assertTrue('FOO' in s1)
|
||||
self.assertNotIn('foo', s)
|
||||
self.assertNotIn('FOo', s)
|
||||
self.assertIn('foo', s1)
|
||||
self.assertIn('FOO', s1)
|
||||
s1.discard('alfkj')
|
||||
s1.remove('FOo')
|
||||
self.assertFalse('foo' in s1)
|
||||
self.assertFalse('FOo' in s1)
|
||||
self.assertNotIn('foo', s1)
|
||||
self.assertNotIn('FOo', s1)
|
||||
|
||||
|
||||
class IrcStringTestCase(SupyTestCase):
|
||||
@ -514,8 +514,8 @@ class IrcStringTestCase(SupyTestCase):
|
||||
def testInequality(self):
|
||||
s1 = 'supybot'
|
||||
s2 = ircutils.IrcString('Supybot')
|
||||
self.assertTrue(s1 == s2)
|
||||
self.assertFalse(s1 != s2)
|
||||
self.assertEqual(s1, s2)
|
||||
self.assertEqual(s1, s2)
|
||||
|
||||
class AuthenticateTestCase(SupyTestCase):
|
||||
PAIRS = [
|
||||
|
@ -74,9 +74,9 @@ class FunctionsTestCase(SupyTestCase):
|
||||
self.assertNotEqual(f(irc, msg, '$today'), '$today')
|
||||
self.assertNotEqual(f(irc, msg, '$now'), '$now')
|
||||
n = f(irc, msg, '$randnick')
|
||||
self.assertTrue(n in irc.state.channels['#foo'].users)
|
||||
self.assertIn(n, irc.state.channels['#foo'].users)
|
||||
n = f(irc, msg, '$randomnick')
|
||||
self.assertTrue(n in irc.state.channels['#foo'].users)
|
||||
self.assertIn(n, irc.state.channels['#foo'].users)
|
||||
n = f(irc, msg, '$randomnick '*100)
|
||||
L = n.split()
|
||||
self.assertFalse(all(L[0].__eq__, L), 'all $randomnicks were the same')
|
||||
|
@ -74,7 +74,7 @@ class GenTest(SupyTestCase):
|
||||
def testInsensitivePreservingDict(self):
|
||||
ipd = utils.InsensitivePreservingDict
|
||||
d = ipd(dict(Foo=10))
|
||||
self.assertTrue(d['foo'] == 10)
|
||||
self.assertEqual(d['foo'], 10)
|
||||
self.assertEqual(d.keys(), ['Foo'])
|
||||
self.assertEqual(d.get('foo'), 10)
|
||||
self.assertEqual(d.get('Foo'), 10)
|
||||
@ -399,7 +399,7 @@ class StrTest(SupyTestCase):
|
||||
def testEllipsisify(self):
|
||||
f = utils.str.ellipsisify
|
||||
self.assertEqual(f('x'*30, 30), 'x'*30)
|
||||
self.assertTrue(len(f('x'*35, 30)) <= 30)
|
||||
self.assertLessEqual(len(f('x'*35, 30)), 30)
|
||||
self.assertTrue(f(' '.join(['xxxx']*10), 30)[:-3].endswith('xxxx'))
|
||||
|
||||
|
||||
@ -553,7 +553,7 @@ class WebTest(SupyTestCase):
|
||||
if network:
|
||||
def testGetUrlWithSize(self):
|
||||
url = 'http://slashdot.org/'
|
||||
self.assertTrue(len(utils.web.getUrl(url, 1024)) == 1024)
|
||||
self.assertEqual(len(utils.web.getUrl(url, 1024)), 1024)
|
||||
|
||||
class FormatTestCase(SupyTestCase):
|
||||
def testNormal(self):
|
||||
@ -619,10 +619,10 @@ class RingBufferTestCase(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
self.assertTrue(0 in b)
|
||||
self.assertTrue(1 in b)
|
||||
self.assertTrue(2 in b)
|
||||
self.assertFalse(3 in b)
|
||||
self.assertIn(0, b)
|
||||
self.assertIn(1, b)
|
||||
self.assertIn(2, b)
|
||||
self.assertNotIn(3, b)
|
||||
|
||||
def testGetitem(self):
|
||||
L = range(10)
|
||||
@ -711,18 +711,18 @@ class RingBufferTestCase(SupyTestCase):
|
||||
|
||||
def testEq(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
self.assertFalse(b == list(range(3)))
|
||||
self.assertNotEqual(b, list(range(3)))
|
||||
b1 = RingBuffer(3)
|
||||
self.assertFalse(b == b1)
|
||||
self.assertNotEqual(b, b1)
|
||||
b1.append(0)
|
||||
self.assertFalse(b == b1)
|
||||
self.assertNotEqual(b, b1)
|
||||
b1.append(1)
|
||||
self.assertFalse(b == b1)
|
||||
self.assertNotEqual(b, b1)
|
||||
b1.append(2)
|
||||
self.assertTrue(b == b1)
|
||||
self.assertEqual(b, b1)
|
||||
b = RingBuffer(100, range(10))
|
||||
b1 = RingBuffer(10, range(10))
|
||||
self.assertFalse(b == b1)
|
||||
self.assertNotEqual(b, b1)
|
||||
|
||||
def testIter(self):
|
||||
b = RingBuffer(3, range(3))
|
||||
@ -799,24 +799,24 @@ class QueueTest(SupyTestCase):
|
||||
def testEq(self):
|
||||
q1 = queue()
|
||||
q2 = queue()
|
||||
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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q2, 'initialized queues not equal')
|
||||
q1.enqueue(1)
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
q2.enqueue(1)
|
||||
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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q2, 'queues not equal after identical enqueue')
|
||||
q1.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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertNotEqual(q1, q2, 'queues equal after one dequeue')
|
||||
q2.dequeue()
|
||||
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')
|
||||
self.assertEqual(q1, q2, 'queues not equal after both are dequeued')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
|
||||
def testInit(self):
|
||||
self.assertEqual(len(queue()), 0, 'queue len not 0 after init')
|
||||
@ -876,17 +876,17 @@ class QueueTest(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
q = queue()
|
||||
self.assertFalse(1 in q, 'empty queue cannot have elements')
|
||||
self.assertNotIn(1, q, 'empty queue cannot have elements')
|
||||
q.enqueue(1)
|
||||
self.assertTrue(1 in q, 'recent enqueued element not in q')
|
||||
self.assertIn(1, q, 'recent enqueued element not in q')
|
||||
q.enqueue(2)
|
||||
self.assertTrue(1 in q, 'original enqueued element not in q')
|
||||
self.assertTrue(2 in q, 'second enqueued element not in q')
|
||||
self.assertIn(1, q, 'original enqueued element not in q')
|
||||
self.assertIn(2, q, 'second enqueued element not in q')
|
||||
q.dequeue()
|
||||
self.assertFalse(1 in q, 'dequeued element in q')
|
||||
self.assertTrue(2 in q, 'not dequeued element not in q')
|
||||
self.assertNotIn(1, q, 'dequeued element in q')
|
||||
self.assertIn(2, q, 'not dequeued element not in q')
|
||||
q.dequeue()
|
||||
self.assertFalse(2 in q, 'dequeued element in q')
|
||||
self.assertNotIn(2, q, 'dequeued element in q')
|
||||
|
||||
def testIter(self):
|
||||
q1 = queue((1, 2, 3))
|
||||
@ -964,24 +964,24 @@ class SmallQueueTest(SupyTestCase):
|
||||
def testEq(self):
|
||||
q1 = queue()
|
||||
q2 = queue()
|
||||
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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q2, 'initialized queues not equal')
|
||||
q1.enqueue(1)
|
||||
self.assertTrue(q1 == q1, 'queue not equal to itself')
|
||||
self.assertTrue(q2 == q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
q2.enqueue(1)
|
||||
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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertEqual(q1, q2, 'queues not equal after identical enqueue')
|
||||
q1.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')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
self.assertNotEqual(q1, q2, 'queues equal after one dequeue')
|
||||
q2.dequeue()
|
||||
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')
|
||||
self.assertEqual(q1, q2, 'queues not equal after both are dequeued')
|
||||
self.assertEqual(q1, q1, 'queue not equal to itself')
|
||||
self.assertEqual(q2, q2, 'queue not equal to itself')
|
||||
|
||||
def testInit(self):
|
||||
self.assertEqual(len(queue()), 0, 'queue len not 0 after init')
|
||||
@ -1041,17 +1041,17 @@ class SmallQueueTest(SupyTestCase):
|
||||
|
||||
def testContains(self):
|
||||
q = queue()
|
||||
self.assertFalse(1 in q, 'empty queue cannot have elements')
|
||||
self.assertNotIn(1, q, 'empty queue cannot have elements')
|
||||
q.enqueue(1)
|
||||
self.assertTrue(1 in q, 'recent enqueued element not in q')
|
||||
self.assertIn(1, q, 'recent enqueued element not in q')
|
||||
q.enqueue(2)
|
||||
self.assertTrue(1 in q, 'original enqueued element not in q')
|
||||
self.assertTrue(2 in q, 'second enqueued element not in q')
|
||||
self.assertIn(1, q, 'original enqueued element not in q')
|
||||
self.assertIn(2, q, 'second enqueued element not in q')
|
||||
q.dequeue()
|
||||
self.assertFalse(1 in q, 'dequeued element in q')
|
||||
self.assertTrue(2 in q, 'not dequeued element not in q')
|
||||
self.assertNotIn(1, q, 'dequeued element in q')
|
||||
self.assertIn(2, q, 'not dequeued element not in q')
|
||||
q.dequeue()
|
||||
self.assertFalse(2 in q, 'dequeued element in q')
|
||||
self.assertNotIn(2, q, 'dequeued element in q')
|
||||
|
||||
def testIter(self):
|
||||
q1 = queue((1, 2, 3))
|
||||
@ -1092,28 +1092,28 @@ class MaxLengthQueueTestCase(SupyTestCase):
|
||||
class TwoWayDictionaryTestCase(SupyTestCase):
|
||||
def testInit(self):
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
self.assertTrue('foo' in d)
|
||||
self.assertTrue('bar' in d)
|
||||
self.assertIn('foo', d)
|
||||
self.assertIn('bar', d)
|
||||
|
||||
d = TwoWayDictionary({1: 2})
|
||||
self.assertTrue(1 in d)
|
||||
self.assertTrue(2 in d)
|
||||
self.assertIn(1, d)
|
||||
self.assertIn(2, d)
|
||||
|
||||
def testSetitem(self):
|
||||
d = TwoWayDictionary()
|
||||
d['foo'] = 'bar'
|
||||
self.assertTrue('foo' in d)
|
||||
self.assertTrue('bar' in d)
|
||||
self.assertIn('foo', d)
|
||||
self.assertIn('bar', d)
|
||||
|
||||
def testDelitem(self):
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
del d['foo']
|
||||
self.assertFalse('foo' in d)
|
||||
self.assertFalse('bar' in d)
|
||||
self.assertNotIn('foo', d)
|
||||
self.assertNotIn('bar', d)
|
||||
d = TwoWayDictionary(foo='bar')
|
||||
del d['bar']
|
||||
self.assertFalse('bar' in d)
|
||||
self.assertFalse('foo' in d)
|
||||
self.assertNotIn('bar', d)
|
||||
self.assertNotIn('foo', d)
|
||||
|
||||
|
||||
class TestTimeoutQueue(SupyTestCase):
|
||||
@ -1146,11 +1146,11 @@ class TestTimeoutQueue(SupyTestCase):
|
||||
def testContains(self):
|
||||
q = TimeoutQueue(1)
|
||||
q.enqueue(1)
|
||||
self.assertTrue(1 in q)
|
||||
self.assertTrue(1 in q) # For some reason, the second one might fail.
|
||||
self.assertFalse(2 in q)
|
||||
self.assertIn(1, q)
|
||||
self.assertIn(1, q) # For some reason, the second one might fail.
|
||||
self.assertNotIn(2, q)
|
||||
timeFastForward(1.1)
|
||||
self.assertFalse(1 in q)
|
||||
self.assertNotIn(1, q)
|
||||
|
||||
def testIter(self):
|
||||
q = TimeoutQueue(1)
|
||||
@ -1178,9 +1178,9 @@ class TestTimeoutQueue(SupyTestCase):
|
||||
def testReset(self):
|
||||
q = TimeoutQueue(10)
|
||||
q.enqueue(1)
|
||||
self.assertTrue(1 in q)
|
||||
self.assertIn(1, q)
|
||||
q.reset()
|
||||
self.assertFalse(1 in q)
|
||||
self.assertNotIn(1, q)
|
||||
|
||||
def testClean(self):
|
||||
def iter_and_next(q):
|
||||
@ -1213,9 +1213,9 @@ class TestCacheDict(SupyTestCase):
|
||||
d = CacheDict(10)
|
||||
for i in range(max**2):
|
||||
d[i] = i
|
||||
self.assertTrue(len(d) <= max)
|
||||
self.assertTrue(i in d)
|
||||
self.assertTrue(d[i] == i)
|
||||
self.assertLessEqual(len(d), max)
|
||||
self.assertIn(i, d)
|
||||
self.assertEqual(d[i], i)
|
||||
|
||||
class TestExpiringDict(SupyTestCase):
|
||||
def testInit(self):
|
||||
@ -1313,14 +1313,14 @@ class TestTruncatableSet(SupyTestCase):
|
||||
def testBasics(self):
|
||||
s = TruncatableSet(['foo', 'bar', 'baz', 'qux'])
|
||||
self.assertEqual(s, set(['foo', 'bar', 'baz', 'qux']))
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertTrue('bar' in s)
|
||||
self.assertFalse('quux' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertIn('bar', s)
|
||||
self.assertNotIn('quux', s)
|
||||
s.discard('baz')
|
||||
self.assertTrue('foo' in s)
|
||||
self.assertFalse('baz' in s)
|
||||
self.assertIn('foo', s)
|
||||
self.assertNotIn('baz', s)
|
||||
s.add('quux')
|
||||
self.assertTrue('quux' in s)
|
||||
self.assertIn('quux', s)
|
||||
|
||||
def testTruncate(self):
|
||||
s = TruncatableSet(['foo', 'bar'])
|
||||
|
Loading…
Reference in New Issue
Block a user