Author: mtredinnick
Date: 2008-07-19 13:47:59 -0500 (Sat, 19 Jul 2008)
New Revision: 7987

Modified:
   django/trunk/tests/regressiontests/forms/fields.py
   django/trunk/tests/regressiontests/forms/forms.py
   django/trunk/tests/regressiontests/forms/models.py
Log:
Fixed #6009 -- Added regression tests to show that uploading non-ASCII
filenames now works properly. Patch from Leah Culver.


Modified: django/trunk/tests/regressiontests/forms/fields.py
===================================================================
--- django/trunk/tests/regressiontests/forms/fields.py  2008-07-19 18:35:11 UTC 
(rev 7986)
+++ django/trunk/tests/regressiontests/forms/fields.py  2008-07-19 18:47:59 UTC 
(rev 7987)
@@ -802,6 +802,9 @@
 >>> type(f.clean(SimpleUploadedFile('name', 'Some File Content')))
 <class 'django.core.files.uploadedfile.SimpleUploadedFile'>
 
+>>> type(f.clean(SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव 
सर्पमीनों से भरी ह')))
+<class 'django.core.files.uploadedfile.SimpleUploadedFile'>
+
 >>> type(f.clean(SimpleUploadedFile('name', 'Some File Content'), 
 >>> 'files/test4.pdf'))
 <class 'django.core.files.uploadedfile.SimpleUploadedFile'>
 

Modified: django/trunk/tests/regressiontests/forms/forms.py
===================================================================
--- django/trunk/tests/regressiontests/forms/forms.py   2008-07-19 18:35:11 UTC 
(rev 7986)
+++ django/trunk/tests/regressiontests/forms/forms.py   2008-07-19 18:47:59 UTC 
(rev 7987)
@@ -1480,6 +1480,10 @@
 >>> f.is_valid()
 True
 
+>>> f = FileForm(data={}, files={'file1': SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 
'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह')}, auto_id=False)
+>>> print f
+<tr><th>File1:</th><td><input type="file" name="file1" /></td></tr>
+
 # Basic form processing in a view #############################################
 
 >>> from django.template import Template, Context

Modified: django/trunk/tests/regressiontests/forms/models.py
===================================================================
--- django/trunk/tests/regressiontests/forms/models.py  2008-07-19 18:35:11 UTC 
(rev 7986)
+++ django/trunk/tests/regressiontests/forms/models.py  2008-07-19 18:47:59 UTC 
(rev 7987)
@@ -1,6 +1,10 @@
+# -*- coding: utf-8 -*-
 import datetime
 
 from django.db import models
+# Can't import as "forms" due to implementation details in the test suite (the
+# current file is called "forms" an is already imported).
+from django import forms as django_forms
 
 class BoundaryModel(models.Model):
     positive_integer = models.PositiveIntegerField(null=True, blank=True)
@@ -14,9 +18,24 @@
     """For ModelChoiceField and ModelMultipleChoiceField tests."""
     name = models.CharField(max_length=10)
 
+class FileModel(models.Model):
+    file = models.FileField(upload_to='/')
+
+class FileForm(django_forms.Form):
+    file1 = django_forms.FileField()
+
 __test__ = {'API_TESTS': """
 >>> from django.forms import form_for_model, form_for_instance
+>>> from django.core.files.uploadedfile import SimpleUploadedFile
 
+# FileModel with unicode filename and data #########################
+>>> f = FileForm(data={}, files={'file1': SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 
'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह')}, auto_id=False)
+>>> f.is_valid()
+True
+>>> f.cleaned_data
+{'file1': <SimpleUploadedFile: 我隻氣墊船裝滿晒鱔.txt (text/plain)>}
+>>> m = FileModel.objects.create(file=f.cleaned_data['file1'])
+
 # Boundary conditions on a PostitiveIntegerField #########################
 >>> BoundaryForm = form_for_model(BoundaryModel)
 >>> f = BoundaryForm({'positive_integer':100})


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to