mirror of
https://github.com/django/django.git
synced 2025-07-06 18:59:13 +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:
|
||||
... model = CommaSeparatedInteger
|
||||
|
||||
>>> f = CommaSeparatedIntegerForm().fields['field']
|
||||
>>> f.clean('1,2,3')
|
||||
u'1,2,3'
|
||||
>>> f.clean('1a,2')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter only digits separated by commas.']
|
||||
>>> f.clean(',,,,')
|
||||
u',,,,'
|
||||
>>> f.clean('1.2')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter only digits separated by commas.']
|
||||
>>> f.clean('1,a,2')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Enter only digits separated by commas.']
|
||||
>>> f.clean('1,,2')
|
||||
u'1,,2'
|
||||
>>> f.clean('1')
|
||||
u'1'
|
||||
>>> f = CommaSeparatedIntegerForm({'field': '1,2,3'})
|
||||
>>> f.is_valid()
|
||||
True
|
||||
>>> f.cleaned_data
|
||||
{'field': u'1,2,3'}
|
||||
>>> f = CommaSeparatedIntegerForm({'field': '1a,2'})
|
||||
>>> f.errors
|
||||
{'field': [u'Enter only digits separated by commas.']}
|
||||
>>> f = CommaSeparatedIntegerForm({'field': ',,,,'})
|
||||
>>> f.is_valid()
|
||||
True
|
||||
>>> f.cleaned_data
|
||||
{'field': u',,,,'}
|
||||
>>> f = CommaSeparatedIntegerForm({'field': '1.2'})
|
||||
>>> f.errors
|
||||
{'field': [u'Enter only digits separated by commas.']}
|
||||
>>> f = CommaSeparatedIntegerForm({'field': '1,a,2'})
|
||||
>>> f.errors
|
||||
{'field': [u'Enter only digits separated by commas.']}
|
||||
>>> f = CommaSeparatedIntegerForm({'field': '1,,2'})
|
||||
>>> 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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user