mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-20 17:39:27 +01:00
Fixed bug (no __delitem__) in IrcDict and added test.
This commit is contained in:
parent
6aa1e8a7ed
commit
d596752a5f
@ -222,11 +222,17 @@ class nick(str):
|
||||
class IrcDict(dict):
|
||||
def __contains__(self, s):
|
||||
return dict.__contains__(self, toLower(s))
|
||||
has_key = __contains__
|
||||
|
||||
def __setitem__(self, s, v):
|
||||
dict.__setitem__(self, toLower(s), v)
|
||||
|
||||
def __getitem__(self, s):
|
||||
return dict.__getitem__(self, toLower(s))
|
||||
has_key = __contains__
|
||||
|
||||
def __delitem__(self, s):
|
||||
dict.__delitem__(self, toLower(s))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys, doctest
|
||||
|
@ -137,9 +137,19 @@ class FunctionsTestCase(unittest.TestCase):
|
||||
modes = [plusB, plusE, minusL]
|
||||
self.assertEqual(ircutils.joinModes(modes),
|
||||
['+be-l', plusB[1], plusE[1]])
|
||||
|
||||
|
||||
class IrcDictTestCase(unittest.TestCase):
|
||||
def test(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['#FOO'] = 'bar'
|
||||
self.assertEqual(d['#FOO'], 'bar')
|
||||
self.assertEqual(d['#Foo'], 'bar')
|
||||
self.assertEqual(d['#foo'], 'bar')
|
||||
del d['#fOO']
|
||||
d['jemfinch{}'] = 'bar'
|
||||
self.assertEqual(d['jemfinch{}'], 'bar')
|
||||
self.assertEqual(d['jemfinch[]'], 'bar')
|
||||
self.assertEqual(d['JEMFINCH[]'], 'bar')
|
||||
|
||||
def testContains(self):
|
||||
d = ircutils.IrcDict()
|
||||
d['#FOO'] = None
|
||||
|
Loading…
Reference in New Issue
Block a user