mirror of https://github.com/django/django.git
[1.6.x] Fixed #15625 -- Made message in MultiValueDictKeyError less verbose.
Thanks margieroginski for the suggestion.
Backport of 893198509e
from master
This commit is contained in:
parent
325b03ea84
commit
275497c570
|
@ -298,7 +298,7 @@ class MultiValueDict(dict):
|
||||||
try:
|
try:
|
||||||
list_ = super(MultiValueDict, self).__getitem__(key)
|
list_ = super(MultiValueDict, self).__getitem__(key)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
|
raise MultiValueDictKeyError(repr(key))
|
||||||
try:
|
try:
|
||||||
return list_[-1]
|
return list_[-1]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
|
|
|
@ -234,11 +234,7 @@ class MultiValueDictTests(SimpleTestCase):
|
||||||
[('name', ['Adrian', 'Simon']),
|
[('name', ['Adrian', 'Simon']),
|
||||||
('position', ['Developer'])])
|
('position', ['Developer'])])
|
||||||
|
|
||||||
# MultiValueDictKeyError: "Key 'lastname' not found in
|
six.assertRaisesRegex(self, MultiValueDictKeyError, 'lastname',
|
||||||
# <MultiValueDict: {'position': ['Developer'],
|
|
||||||
# 'name': ['Adrian', 'Simon']}>"
|
|
||||||
six.assertRaisesRegex(self, MultiValueDictKeyError,
|
|
||||||
r'"Key \'lastname\' not found in <MultiValueDict',
|
|
||||||
d.__getitem__, 'lastname')
|
d.__getitem__, 'lastname')
|
||||||
|
|
||||||
self.assertEqual(d.get('lastname'), None)
|
self.assertEqual(d.get('lastname'), None)
|
||||||
|
|
Loading…
Reference in New Issue