]> granicus.if.org Git - python/commitdiff
A test case for the defaultdict KeyError bug.
authorGeorg Brandl <georg@python.org>
Tue, 6 Mar 2007 13:35:08 +0000 (13:35 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 6 Mar 2007 13:35:08 +0000 (13:35 +0000)
 (backport from rev. 54162)

Lib/test/test_defaultdict.py

index 1834f9071ae3f1d6abf791674d7c8d3c88fd63c3..08be005b424be9f8ba6a9d9d9240885d14c548ae 100644 (file)
@@ -132,6 +132,15 @@ class TestDefaultDict(unittest.TestCase):
         self.assertEqual(d2.default_factory, list)
         self.assertEqual(d2, d1)
 
+    def test_keyerror_without_factory(self):
+        d1 = defaultdict()
+        try:
+            d1[(1,)]
+        except KeyError, err:
+            self.assertEqual(err.message, (1,))
+        else:
+            self.fail("expected KeyError")
+
 
 def test_main():
     test_support.run_unittest(TestDefaultDict)