diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-05-03 11:52:04 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-05-03 11:52:04 +0000 |
| commit | 41a1a89e4ede058f35f2ff6da18a828ac059d785 (patch) | |
| tree | 108bc1ebc479db875d5241d7faf0bc80df9fbfb7 /tests | |
| parent | 48cffd9e459d8aaf9d1afa36f4e07f9624b2c4ad (diff) | |
Fixed #12595 -- Fixed bad arguments handling in localflavor form fields.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16146 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/forms/localflavor/utils.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/tests/regressiontests/forms/localflavor/utils.py b/tests/regressiontests/forms/localflavor/utils.py index 482f7adeab..31d53dd255 100644 --- a/tests/regressiontests/forms/localflavor/utils.py +++ b/tests/regressiontests/forms/localflavor/utils.py @@ -1,5 +1,6 @@ from django.core.exceptions import ValidationError from django.core.validators import EMPTY_VALUES +from django.forms.fields import CharField from django.test.utils import get_warnings_state, restore_warnings_state from django.utils.unittest import TestCase @@ -13,8 +14,8 @@ class LocalFlavorTestCase(TestCase): def restore_warnings_state(self): restore_warnings_state(self._warnings_state) - def assertFieldOutput(self, fieldclass, valid, invalid, field_args=[], - field_kwargs={}, empty_value=u''): + def assertFieldOutput(self, fieldclass, valid, invalid, field_args=None, + field_kwargs=None, empty_value=u''): """ Asserts that a field behaves correctly with various inputs. @@ -29,6 +30,10 @@ class LocalFlavorTestCase(TestCase): empty_value: the expected clean output for inputs in EMPTY_VALUES """ + if field_args is None: + field_args = [] + if field_kwargs is None: + field_kwargs = {} required = fieldclass(*field_args, **field_kwargs) optional = fieldclass(*field_args, **dict(field_kwargs, required=False)) # test valid inputs @@ -49,3 +54,7 @@ class LocalFlavorTestCase(TestCase): self.assertRaisesRegexp(ValidationError, error_required, required.clean, e) self.assertEqual(optional.clean(e), empty_value) + # test that max_length and min_length are always accepted + if issubclass(fieldclass, CharField): + field_kwargs.update({'min_length':2, 'max_length':20}) + self.assertTrue(isinstance(fieldclass(*field_args, **field_kwargs), fieldclass)) |
