From 9def8a49bd84780c369527280f9e544f6ca60e36 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 5 Feb 2004 07:32:20 +0000 Subject: [PATCH] Hmm, didn't define keys. --- src/utils.py | 9 +++++++-- test/test_ircutils.py | 4 ++++ test/test_utils.py | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/utils.py b/src/utils.py index fdb183754..5070ea3b7 100755 --- a/src/utils.py +++ b/src/utils.py @@ -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()),)) diff --git a/test/test_ircutils.py b/test/test_ircutils.py index c3ce44965..f13f16085 100644 --- a/test/test_ircutils.py +++ b/test/test_ircutils.py @@ -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) diff --git a/test/test_utils.py b/test/test_utils.py index bf2eac647..dfb67bafb 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -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: