Hmm, didn't define keys.

This commit is contained in:
Jeremy Fincher 2004-02-05 07:32:20 +00:00
parent 19a86f3873
commit 9def8a49bd
3 changed files with 12 additions and 2 deletions

View File

@ -601,8 +601,13 @@ class InsensitivePreservingDict(UserDict.DictMixin, object):
del self.data[self.key(k)]
def iteritems(self):
for t in self.data.itervalues():
yield t
return self.data.itervalues()
def keys(self):
L = []
for (k, _) in self.iteritems():
L.append(k)
return L
def __reduce__(self):
return (self.__class__, (dict(self.data.values()),))

View File

@ -212,6 +212,10 @@ class IrcDictTestCase(unittest.TestCase):
self.assertEqual(d['jemfinch[]'], 'bar')
self.assertEqual(d['JEMFINCH[]'], 'bar')
def testKeys(self):
d = ircutils.IrcDict()
self.assertEqual(d.keys(), [])
def testSetdefault(self):
d = ircutils.IrcDict()
d.setdefault('#FOO', []).append(1)

View File

@ -349,6 +349,7 @@ class UtilsTest(unittest.TestCase):
ipd = utils.InsensitivePreservingDict
d = ipd(dict(Foo=10))
self.failUnless(d['foo'] == 10)
self.assertEqual(d.keys(), ['Foo'])
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: