A test case for the defaultdict KeyError bug.

(backport from rev. 54162)
This commit is contained in:
Georg Brandl 2007-03-06 13:35:08 +00:00
parent 75e3c527f6
commit 1a74b4325c
1 changed files with 9 additions and 0 deletions

View 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)