mirror of https://github.com/django/django.git
Fixed #20321 -- Added missing key name in MergeDict KeyError message
Thanks mark.harviston et gmail.com for the report.
This commit is contained in:
parent
6bccbc05a4
commit
4769db6b5f
|
@ -26,7 +26,7 @@ class MergeDict(object):
|
||||||
return dict_[key]
|
return dict_[key]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
raise KeyError
|
raise KeyError(key)
|
||||||
|
|
||||||
def __copy__(self):
|
def __copy__(self):
|
||||||
return self.__class__(*self.dicts)
|
return self.__class__(*self.dicts)
|
||||||
|
|
|
@ -209,6 +209,14 @@ class MergeDictTests(SimpleTestCase):
|
||||||
self.assertFalse(empty)
|
self.assertFalse(empty)
|
||||||
self.assertTrue(not_empty)
|
self.assertTrue(not_empty)
|
||||||
|
|
||||||
|
def test_key_error(self):
|
||||||
|
"""
|
||||||
|
Test that the message of KeyError contains the missing key name.
|
||||||
|
"""
|
||||||
|
d1 = MergeDict({'key1': 42})
|
||||||
|
with six.assertRaisesRegex(self, KeyError, 'key2'):
|
||||||
|
d1['key2']
|
||||||
|
|
||||||
|
|
||||||
class MultiValueDictTests(SimpleTestCase):
|
class MultiValueDictTests(SimpleTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue