diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2010-11-19 23:56:38 +0000 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2010-11-19 23:56:38 +0000 |
| commit | 7236b76e25d34947c8090c8061ebdf46cc233584 (patch) | |
| tree | 934a954448d492ce02ac9890783728ee656c80d5 | |
| parent | 8d3e66fad61c96aa2269a2a3ca38fb3f5cab1189 (diff) | |
Corrected some issues with the backport from [14627].
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14634 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | tests/regressiontests/forms/localflavor/utils.py | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/regressiontests/forms/localflavor/utils.py b/tests/regressiontests/forms/localflavor/utils.py index 3297d4e10c..0404035031 100644 --- a/tests/regressiontests/forms/localflavor/utils.py +++ b/tests/regressiontests/forms/localflavor/utils.py @@ -1,6 +1,7 @@ +from unittest import TestCase + from django.core.exceptions import ValidationError from django.core.validators import EMPTY_VALUES -from django.utils.unittest import TestCase class LocalFlavorTestCase(TestCase): @@ -23,16 +24,25 @@ class LocalFlavorTestCase(TestCase): self.assertEqual(optional.clean(input), output) # test invalid inputs for input, errors in invalid.items(): - self.assertRaisesRegexp(ValidationError, unicode(errors), - required.clean, input - ) - self.assertRaisesRegexp(ValidationError, unicode(errors), - optional.clean, input - ) + try: + required.clean(input) + except ValidationError, e: + self.assertTrue(unicode(errors) in unicode(e)) + else: + self.fail() + try: + optional.clean(input) + except ValidationError, e: + self.assertTrue(unicode(errors) in unicode(e)) + else: + self.fail() # test required inputs error_required = u'This field is required' - for e in EMPTY_VALUES: - self.assertRaisesRegexp(ValidationError, error_required, - required.clean, e - ) - self.assertEqual(optional.clean(e), u'') + for val in EMPTY_VALUES: + try: + required.clean(val) + except ValidationError, e: + self.assertTrue(error_required in unicode(e)) + else: + self.fail() + self.assertEqual(optional.clean(val), u'') |
