Ticket #17499: 17499-2.diff

File 17499-2.diff, 2.2 KB (added by Claude Paroz, 13 years ago)

Same patch with test

  • django/test/testcases.py

    diff --git a/django/test/testcases.py b/django/test/testcases.py
    index 4de4750..53ea02a 100644
    a b from django.test.client import Client  
    3131from django.test.utils import (get_warnings_state, restore_warnings_state,
    3232    override_settings)
    3333from django.utils import simplejson, unittest as ut2
    34 from django.utils.encoding import smart_str
     34from django.utils.encoding import smart_str, force_unicode
    3535from django.views.static import serve
    3636
    3737__all__ = ('DocTestRunner', 'OutputChecker', 'TestCase', 'TransactionTestCase',
    class SimpleTestCase(ut2.TestCase):  
    335335                optional.clean(input)
    336336            self.assertEqual(context_manager.exception.messages, errors)
    337337        # test required inputs
    338         error_required = [u'This field is required.']
     338        error_required = [force_unicode(required.error_messages['required'])]
    339339        for e in EMPTY_VALUES:
    340340            with self.assertRaises(ValidationError) as context_manager:
    341341                required.clean(e)
  • tests/regressiontests/test_utils/tests.py

    diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
    index c192d51..eab6895 100644
    a b  
    11from __future__ import with_statement, absolute_import
    22
    3 from django.forms import EmailField
     3from django.forms import EmailField, IntegerField
    44from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
    55from django.utils.unittest import skip
    66
    class AssertFieldOutputTests(SimpleTestCase):  
    149149        self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'Wrong output'}, {'aaa': error_invalid})
    150150        self.assertRaises(AssertionError, self.assertFieldOutput, EmailField, {'a@a.com': 'a@a.com'}, {'aaa': [u'Come on, gimme some well formatted data, dude.']})
    151151
     152    def test_custom_required_message(self):
     153        class MyCustomField(IntegerField):
     154            default_error_messages = {
     155                'required': u'This is really required.',
     156            }
     157        self.assertFieldOutput(MyCustomField, {}, {}, empty_value=None)
    152158
    153159__test__ = {"API_TEST": r"""
    154160# Some checks of the doctest output normalizer.
Back to Top