mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +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):
|
class IrcDict(dict):
|
||||||
def __contains__(self, s):
|
def __contains__(self, s):
|
||||||
return dict.__contains__(self, toLower(s))
|
return dict.__contains__(self, toLower(s))
|
||||||
|
has_key = __contains__
|
||||||
|
|
||||||
def __setitem__(self, s, v):
|
def __setitem__(self, s, v):
|
||||||
dict.__setitem__(self, toLower(s), v)
|
dict.__setitem__(self, toLower(s), v)
|
||||||
|
|
||||||
def __getitem__(self, s):
|
def __getitem__(self, s):
|
||||||
return dict.__getitem__(self, toLower(s))
|
return dict.__getitem__(self, toLower(s))
|
||||||
has_key = __contains__
|
|
||||||
|
def __delitem__(self, s):
|
||||||
|
dict.__delitem__(self, toLower(s))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import sys, doctest
|
import sys, doctest
|
||||||
|
@ -137,9 +137,19 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
modes = [plusB, plusE, minusL]
|
modes = [plusB, plusE, minusL]
|
||||||
self.assertEqual(ircutils.joinModes(modes),
|
self.assertEqual(ircutils.joinModes(modes),
|
||||||
['+be-l', plusB[1], plusE[1]])
|
['+be-l', plusB[1], plusE[1]])
|
||||||
|
|
||||||
|
|
||||||
class IrcDictTestCase(unittest.TestCase):
|
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):
|
def testContains(self):
|
||||||
d = ircutils.IrcDict()
|
d = ircutils.IrcDict()
|
||||||
d['#FOO'] = None
|
d['#FOO'] = None
|
||||||
|
Loading…
Reference in New Issue
Block a user