Skip to content

Commit

Permalink
Corrected some issues with the backport from [14627].
Browse files Browse the repository at this point in the history
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14634 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
alex committed Nov 19, 2010
1 parent 8d3e66f commit 7236b76
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions tests/regressiontests/forms/localflavor/utils.py
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest import TestCase

from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.validators import EMPTY_VALUES from django.core.validators import EMPTY_VALUES
from django.utils.unittest import TestCase




class LocalFlavorTestCase(TestCase): class LocalFlavorTestCase(TestCase):
Expand All @@ -23,16 +24,25 @@ def assertFieldOutput(self, fieldclass, valid, invalid):
self.assertEqual(optional.clean(input), output) self.assertEqual(optional.clean(input), output)
# test invalid inputs # test invalid inputs
for input, errors in invalid.items(): for input, errors in invalid.items():
self.assertRaisesRegexp(ValidationError, unicode(errors), try:
required.clean, input required.clean(input)
) except ValidationError, e:
self.assertRaisesRegexp(ValidationError, unicode(errors), self.assertTrue(unicode(errors) in unicode(e))
optional.clean, input else:
) self.fail()
try:
optional.clean(input)
except ValidationError, e:
self.assertTrue(unicode(errors) in unicode(e))
else:
self.fail()
# test required inputs # test required inputs
error_required = u'This field is required' error_required = u'This field is required'
for e in EMPTY_VALUES: for val in EMPTY_VALUES:
self.assertRaisesRegexp(ValidationError, error_required, try:
required.clean, e required.clean(val)
) except ValidationError, e:
self.assertEqual(optional.clean(e), u'') self.assertTrue(error_required in unicode(e))
else:
self.fail()
self.assertEqual(optional.clean(val), u'')

0 comments on commit 7236b76

Please sign in to comment.