mirror of
https://github.com/django/django.git
synced 2025-07-07 11:19:12 +00:00
[soc2009/model-validation] Update model_forms test to actually test model form
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@11396 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
97db2014f8
commit
549b19af81
@ -1338,27 +1338,35 @@ __test__['API_TESTS'] += """
|
|||||||
... class Meta:
|
... class Meta:
|
||||||
... model = CommaSeparatedInteger
|
... model = CommaSeparatedInteger
|
||||||
|
|
||||||
>>> f = CommaSeparatedIntegerForm().fields['field']
|
>>> f = CommaSeparatedIntegerForm({'field': '1,2,3'})
|
||||||
>>> f.clean('1,2,3')
|
>>> f.is_valid()
|
||||||
u'1,2,3'
|
True
|
||||||
>>> f.clean('1a,2')
|
>>> f.cleaned_data
|
||||||
Traceback (most recent call last):
|
{'field': u'1,2,3'}
|
||||||
...
|
>>> f = CommaSeparatedIntegerForm({'field': '1a,2'})
|
||||||
ValidationError: [u'Enter only digits separated by commas.']
|
>>> f.errors
|
||||||
>>> f.clean(',,,,')
|
{'field': [u'Enter only digits separated by commas.']}
|
||||||
u',,,,'
|
>>> f = CommaSeparatedIntegerForm({'field': ',,,,'})
|
||||||
>>> f.clean('1.2')
|
>>> f.is_valid()
|
||||||
Traceback (most recent call last):
|
True
|
||||||
...
|
>>> f.cleaned_data
|
||||||
ValidationError: [u'Enter only digits separated by commas.']
|
{'field': u',,,,'}
|
||||||
>>> f.clean('1,a,2')
|
>>> f = CommaSeparatedIntegerForm({'field': '1.2'})
|
||||||
Traceback (most recent call last):
|
>>> f.errors
|
||||||
...
|
{'field': [u'Enter only digits separated by commas.']}
|
||||||
ValidationError: [u'Enter only digits separated by commas.']
|
>>> f = CommaSeparatedIntegerForm({'field': '1,a,2'})
|
||||||
>>> f.clean('1,,2')
|
>>> f.errors
|
||||||
u'1,,2'
|
{'field': [u'Enter only digits separated by commas.']}
|
||||||
>>> f.clean('1')
|
>>> f = CommaSeparatedIntegerForm({'field': '1,,2'})
|
||||||
u'1'
|
>>> f.is_valid()
|
||||||
|
True
|
||||||
|
>>> f.cleaned_data
|
||||||
|
{'field': u'1,,2'}
|
||||||
|
>>> f = CommaSeparatedIntegerForm({'field': '1'})
|
||||||
|
>>> f.is_valid()
|
||||||
|
True
|
||||||
|
>>> f.cleaned_data
|
||||||
|
{'field': u'1'}
|
||||||
|
|
||||||
# unique/unique_together validation
|
# unique/unique_together validation
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user