diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-01-17 18:03:21 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-01-17 18:03:21 +0000 |
| commit | fd20365b277bf48dbdbd82afa1346eadb96d9574 (patch) | |
| tree | 1e02d91fca33fb2fd52ff26125fe788470da4e3a /tests/regressiontests/forms | |
| parent | 93c8e94bd6b004ae7a97502e664e6a530958ed9a (diff) | |
Fixed #6302. FileField no longer requires a value if one already exists. Thanks Brian Rosner and Øyvind Saltvik.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@7021 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/fields.py | 33 |
1 files changed, 30 insertions, 3 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 ################################################################## |
