diff options
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/fields.py | 33 | ||||
| -rw-r--r-- | tests/regressiontests/forms/localflavor/ca.py | 6 |
2 files changed, 33 insertions, 6 deletions
diff --git a/tests/regressiontests/forms/fields.py b/tests/regressiontests/forms/fields.py index cff5db6fca..9216210e09 100644 --- a/tests/regressiontests/forms/fields.py +++ b/tests/regressiontests/forms/fields.py @@ -749,32 +749,59 @@ Traceback (most recent call last): ... ValidationError: [u'This field is required.'] +>>> f.clean('', '') +Traceback (most recent call last): +... +ValidationError: [u'This field is required.'] + +>>> f.clean('', 'files/test1.pdf') +'files/test1.pdf' + >>> f.clean(None) Traceback (most recent call last): ... ValidationError: [u'This field is required.'] +>>> f.clean(None, '') +Traceback (most recent call last): +... +ValidationError: [u'This field is required.'] + +>>> f.clean(None, 'files/test2.pdf') +'files/test2.pdf' + >>> f.clean({}) Traceback (most recent call last): ... ValidationError: [u'No file was submitted.'] +>>> f.clean({}, '') +Traceback (most recent call last): +... +ValidationError: [u'No file was submitted.'] + +>>> f.clean({}, 'files/test3.pdf') +'files/test3.pdf' + >>> f.clean('some content that is not a file') Traceback (most recent call last): ... ValidationError: [u'No file was submitted. Check the encoding type on the form.'] ->>> f.clean({'filename': 'name', 'content':None}) +>>> f.clean({'filename': 'name', 'content': None}) Traceback (most recent call last): ... ValidationError: [u'The submitted file is empty.'] ->>> f.clean({'filename': 'name', 'content':''}) +>>> f.clean({'filename': 'name', 'content': ''}) Traceback (most recent call last): ... ValidationError: [u'The submitted file is empty.'] ->>> type(f.clean({'filename': 'name', 'content':'Some File Content'})) +>>> type(f.clean({'filename': 'name', 'content': 'Some File Content'})) +<class 'django.newforms.fields.UploadedFile'> + +>>> type(f.clean({'filename': 'name', 'content': 'Some File Content'}, 'files/test4.pdf')) <class 'django.newforms.fields.UploadedFile'> # URLField ################################################################## diff --git a/tests/regressiontests/forms/localflavor/ca.py b/tests/regressiontests/forms/localflavor/ca.py index a13a6de65f..48171b0558 100644 --- a/tests/regressiontests/forms/localflavor/ca.py +++ b/tests/regressiontests/forms/localflavor/ca.py @@ -213,13 +213,13 @@ u'046-454-286' >>> f.clean('046-454-287') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] >>> f.clean('046 454 286') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] >>> f.clean('046-44-286') Traceback (most recent call last): ... -ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'] +ValidationError: [u'Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'] """ |
