mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
Converted Chilean localflavor doctests to unittests. We have always been at war with doctests. Thanks to Idan Gazit.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@14936 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -4,7 +4,8 @@ from django.utils.unittest import TestCase
|
||||
|
||||
|
||||
class LocalFlavorTestCase(TestCase):
|
||||
def assertFieldOutput(self, fieldclass, valid, invalid):
|
||||
def assertFieldOutput(self, fieldclass, valid, invalid, field_args=[],
|
||||
field_kwargs={}, empty_value=u''):
|
||||
"""Asserts that a field behaves correctly with various inputs.
|
||||
|
||||
Args:
|
||||
@@ -13,10 +14,12 @@ class LocalFlavorTestCase(TestCase):
|
||||
cleaned values.
|
||||
invalid: a dictionary mapping invalid inputs to one or more
|
||||
raised error messages.
|
||||
fieldargs: the args passed to instantiate the field
|
||||
fieldkwargs: the kwargs passed to instantiate the field
|
||||
emptyvalue: the expected clean output for inputs in EMPTY_VALUES
|
||||
"""
|
||||
|
||||
required = fieldclass()
|
||||
optional = fieldclass(required=False)
|
||||
required = fieldclass(*field_args, **field_kwargs)
|
||||
optional = fieldclass(*field_args, required=False, **field_kwargs)
|
||||
# test valid inputs
|
||||
for input, output in valid.items():
|
||||
self.assertEqual(required.clean(input), output)
|
||||
@@ -33,6 +36,5 @@ class LocalFlavorTestCase(TestCase):
|
||||
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'')
|
||||
required.clean, e)
|
||||
self.assertEqual(optional.clean(e), empty_value)
|
||||
|
||||
Reference in New Issue
Block a user