diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2019-10-08 09:38:28 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-10-08 10:07:05 +0200 |
| commit | a28d1b38e55cf588cfaae97de6a575d5c9f90a96 (patch) | |
| tree | 3948c97d073f934759676edc4a65d4e1e0603f2d /tests/forms_tests | |
| parent | 06909fe084f87a65459a83bd69d7cdbe4fce9a7c (diff) | |
Fixed #30839 -- Fixed Field.__deepcopy__() so forms don't share error messages.
Diffstat (limited to 'tests/forms_tests')
| -rw-r--r-- | tests/forms_tests/tests/test_forms.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py index 45f5405fee..269567dac8 100644 --- a/tests/forms_tests/tests/test_forms.py +++ b/tests/forms_tests/tests/test_forms.py @@ -3685,6 +3685,17 @@ Good luck picking a username that doesn't already exist.</p> self.assertIsInstance(p.data, MultiValueDict) self.assertIsInstance(p.files, MultiValueDict) + def test_field_deep_copy_error_messages(self): + class CustomCharField(CharField): + def __init__(self, **kwargs): + kwargs['error_messages'] = {'invalid': 'Form custom error message.'} + super().__init__(**kwargs) + + field = CustomCharField() + field_copy = copy.deepcopy(field) + self.assertIsInstance(field_copy, CustomCharField) + self.assertIsNot(field_copy.error_messages, field.error_messages) + class CustomRenderer(DjangoTemplates): pass |
