Fixed #15625 -- Made message in MultiValueDictKeyError less verbose.
Thanks margieroginski for the suggestion.
This commit is contained in:
parent
50633e7353
commit
893198509e
|
@ -307,7 +307,7 @@ class MultiValueDict(dict):
|
|||
try:
|
||||
list_ = super(MultiValueDict, self).__getitem__(key)
|
||||
except KeyError:
|
||||
raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
|
||||
raise MultiValueDictKeyError(repr(key))
|
||||
try:
|
||||
return list_[-1]
|
||||
except IndexError:
|
||||
|
|
|
@ -221,11 +221,7 @@ class MultiValueDictTests(SimpleTestCase):
|
|||
[('name', ['Adrian', 'Simon']),
|
||||
('position', ['Developer'])])
|
||||
|
||||
# MultiValueDictKeyError: "Key 'lastname' not found in
|
||||
# <MultiValueDict: {'position': ['Developer'],
|
||||
# 'name': ['Adrian', 'Simon']}>"
|
||||
six.assertRaisesRegex(self, MultiValueDictKeyError,
|
||||
r'"Key \'lastname\' not found in <MultiValueDict',
|
||||
six.assertRaisesRegex(self, MultiValueDictKeyError, 'lastname',
|
||||
d.__getitem__, 'lastname')
|
||||
|
||||
self.assertEqual(d.get('lastname'), None)
|
||||
|
|
Loading…
Reference in New Issue