0
0
mirror of https://github.com/django/django.git synced 2024-12-01 15:42:04 +01:00

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: try:
list_ = super().__getitem__(key) list_ = super().__getitem__(key)
except KeyError: except KeyError:
raise MultiValueDictKeyError(repr(key)) raise MultiValueDictKeyError(key)
try: try:
return list_[-1] return list_[-1]
except IndexError: except IndexError:

View File

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