diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index f4f694f399..2f60c29cb0 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -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: diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py index 263a5d4be7..5887cad085 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -221,11 +221,7 @@ class MultiValueDictTests(SimpleTestCase): [('name', ['Adrian', 'Simon']), ('position', ['Developer'])]) - # MultiValueDictKeyError: "Key 'lastname' not found in - # " - six.assertRaisesRegex(self, MultiValueDictKeyError, - r'"Key \'lastname\' not found in