From fd20365b277bf48dbdbd82afa1346eadb96d9574 Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Thu, 17 Jan 2008 18:03:21 +0000 Subject: Fixed #6302. FileField no longer requires a value if one already exists. Thanks Brian Rosner and Øyvind Saltvik. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://code.djangoproject.com/svn/django/trunk@7021 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/forms/fields.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'tests/regressiontests/forms') 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'})) + + +>>> type(f.clean({'filename': 'name', 'content': 'Some File Content'}, 'files/test4.pdf')) # URLField ################################################################## -- cgit v1.3