Browse files

Fixed #15625 -- Made message in MultiValueDictKeyError less verbose.

Thanks margieroginski for the suggestion.
  • Loading branch information...
1 parent 50633e7 commit 893198509e3b821a56a56e4326929e0613aad983 @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
@@ -307,7 +307,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
@@ -221,11 +221,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 8931985

Please sign in to comment.