def test_date_field_raises_error_message(self):
        f = models.DateField()
        self.assertRaises(ValidationError, f.clean, 'foo', None)
        try:
            f.clean('foo', None)
        except ValidationError, e:
            self.assertEqual(e.messages, [
                u"'foo' value has an invalid date format. "
                u"It must be in YYYY-MM-DD format."])

        self.assertRaises(ValidationError, f.clean, 'aaaa-10-10', None)
        try:
            f.clean('aaaa-10-10', None)
        except __HOLE__, e:
            self.assertEqual(e.messages, [
                u"'aaaa-10-10' value has an invalid date format. "
                u"It must be in YYYY-MM-DD format."])

        self.assertRaises(ValidationError, f.clean, '2011-13-10', None)
        try:
            f.clean('2011-13-10', None)
        except ValidationError, e:
            self.assertEqual(e.messages, [
                u"'2011-13-10' value has the correct format (YYYY-MM-DD) "
                u"but it is an invalid date."])

        self.assertRaises(ValidationError, f.clean, '2011-10-32', None)
        try:
            f.clean('2011-10-32', None)
        except ValidationError, e:
            self.assertEqual(e.messages, [
                u"'2011-10-32' value has the correct format (YYYY-MM-DD) "
                u"but it is an invalid date."])
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/tests/modeltests/validation/test_error_messages.py/ValidationMessagesTest.test_date_field_raises_error_message