Fixed #28064 -- Removed double-quoting of key names in MultiValueDictKeyError.

This commit is contained in:
petedmarsh 2017-04-11 17:44:52 +01:00 committed by Tim Graham
parent 7060f777b0
commit 14671affc3
2 changed files with 3 additions and 2 deletions

View File

@ -76,7 +76,7 @@ class MultiValueDict(dict):
try:
list_ = super().__getitem__(key)
except KeyError:
raise MultiValueDictKeyError(repr(key))
raise MultiValueDictKeyError(key)
try:
return list_[-1]
except IndexError:

View File

@ -48,8 +48,9 @@ class MultiValueDictTests(SimpleTestCase):
[('name', ['Adrian', 'Simon']), ('position', ['Developer'])]
)
with self.assertRaisesMessage(MultiValueDictKeyError, 'lastname'):
with self.assertRaises(MultiValueDictKeyError) as cm:
d.__getitem__('lastname')
self.assertEqual(str(cm.exception), "'lastname'")
self.assertIsNone(d.get('lastname'))
self.assertEqual(d.get('lastname', 'nonexistent'), 'nonexistent')