Permalink
Browse files

[1.6.x] Fixed #15625 -- Made message in MultiValueDictKeyError less v…

…erbose.

Thanks margieroginski for the suggestion.

Backport of 8931985 from master
  • Loading branch information...
1 parent 325b03e commit 275497c5709792b47c71538a7e58bb40e8d8d3a9 @timgraham timgraham committed Sep 16, 2013
Showing with 2 additions and 6 deletions.
  1. +1 −1 django/utils/datastructures.py
  2. +1 −5 tests/utils_tests/test_datastructures.py
View
2 django/utils/datastructures.py
@@ -298,7 +298,7 @@ def __getitem__(self, key):
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:
View
6 tests/utils_tests/test_datastructures.py
@@ -234,11 +234,7 @@ def test_multivaluedict(self):
[('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)

0 comments on commit 275497c

Please sign in to comment.