From 14671affc346e70f6bb24117fd4e6af72895864b Mon Sep 17 00:00:00 2001 From: petedmarsh Date: Tue, 11 Apr 2017 17:44:52 +0100 Subject: [PATCH] Fixed #28064 -- Removed double-quoting of key names in MultiValueDictKeyError. --- django/utils/datastructures.py | 2 +- tests/utils_tests/test_datastructures.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/django/utils/datastructures.py b/django/utils/datastructures.py index aba5bcf1c2..a21de8a74a 100644 --- a/django/utils/datastructures.py +++ b/django/utils/datastructures.py @@ -76,7 +76,7 @@ class MultiValueDict(dict): try: list_ = super().__getitem__(key) except KeyError: - raise MultiValueDictKeyError(repr(key)) + raise MultiValueDictKeyError(key) try: return list_[-1] except IndexError: diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py index df7020eac5..e66210759a 100644 --- a/tests/utils_tests/test_datastructures.py +++ b/tests/utils_tests/test_datastructures.py @@ -48,8 +48,9 @@ class MultiValueDictTests(SimpleTestCase): [('name', ['Adrian', 'Simon']), ('position', ['Developer'])] ) - with self.assertRaisesMessage(MultiValueDictKeyError, 'lastname'): + with self.assertRaises(MultiValueDictKeyError) as cm: d.__getitem__('lastname') + self.assertEqual(str(cm.exception), "'lastname'") self.assertIsNone(d.get('lastname')) self.assertEqual(d.get('lastname', 'nonexistent'), 'nonexistent')