diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index a2113233207..f854933feaf 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -298,7 +298,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 2692b85a7d5..f67fff0a4b9 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -234,11 +234,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