Ticket #30839: test-30839.diff

File test-30839.diff, 1.4 KB (added by Mariusz Felisiak, 5 years ago)

Simple test.

  • tests/model_forms/tests.py

    diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
    index e264b6df77..20905bc124 100644
    a b class OtherModelFormTests(TestCase):  
    25442544class ModelFormCustomErrorTests(SimpleTestCase):
    25452545    def test_custom_error_messages(self):
    25462546        data = {'name1': '@#$!!**@#$', 'name2': '@#$!!**@#$'}
    2547         errors = CustomErrorMessageForm(data).errors
     2547        form1 = CustomErrorMessageForm(data)
     2548        form2 = CustomErrorMessageForm(data)
     2549        form2.fields['name1'].error_messages['invalid'] = 'new message for form2'
     2550        errors = form1.errors
    25482551        self.assertHTMLEqual(
    25492552            str(errors['name1']),
    25502553            '<ul class="errorlist"><li>Form custom error message.</li></ul>'
    class ModelFormCustomErrorTests(SimpleTestCase):  
    25532556            str(errors['name2']),
    25542557            '<ul class="errorlist"><li>Model custom error message.</li></ul>'
    25552558        )
     2559        errors = form2.errors
     2560        self.assertHTMLEqual(
     2561            str(errors['name1']),
     2562            '<ul class="errorlist"><li>new message for form2</li></ul>'
     2563        )
     2564        self.assertHTMLEqual(
     2565            str(errors['name2']),
     2566            '<ul class="errorlist"><li>Model custom error message.</li></ul>'
     2567        )
    25562568
    25572569    def test_model_clean_error_messages(self):
    25582570        data = {'name1': 'FORBIDDEN_VALUE', 'name2': 'ABC'}
Back to Top