Ticket #6009: patch-6009-1.diff
File patch-6009-1.diff, 3.0 KB (added by , 16 years ago) |
---|
-
tests/regressiontests/forms/models.py
1 # -*- coding: utf-8 -*- 1 2 import datetime 2 3 3 4 from django.db import models 5 from django import newforms as django_forms 4 6 5 7 class BoundaryModel(models.Model): 6 8 positive_integer = models.PositiveIntegerField(null=True, blank=True) … … 14 16 """For ModelChoiceField and ModelMultipleChoiceField tests.""" 15 17 name = models.CharField(max_length=10) 16 18 19 class FileModel(models.Model): 20 file = models.FileField(upload_to='/') 21 22 class FileForm(django_forms.Form): 23 file1 = django_forms.FileField() 24 17 25 __test__ = {'API_TESTS': """ 26 27 >>> from django.core.files.uploadedfile import SimpleUploadedFile 18 28 >>> from django.newforms import form_for_model, form_for_instance 19 29 30 # FileModel with unicode filename and data ######################### 31 >>> f = FileForm(data={}, files={'file1': SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह')}, auto_id=False) 32 >>> f.is_valid() 33 True 34 >>> f.cleaned_data 35 {'file1': <SimpleUploadedFile: 我隻氣墊船裝滿晒鱔.txt (text/plain)>} 36 >>> m = FileModel.objects.create(file=f.cleaned_data['file1']) 37 20 38 # Boundary conditions on a PostitiveIntegerField ######################### 21 39 >>> BoundaryForm = form_for_model(BoundaryModel) 22 40 >>> f = BoundaryForm({'positive_integer':100}) -
tests/regressiontests/forms/fields.py
802 802 >>> type(f.clean(SimpleUploadedFile('name', 'Some File Content'))) 803 803 <class 'django.core.files.uploadedfile.SimpleUploadedFile'> 804 804 805 >>> type(f.clean(SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह'))) 806 <class 'django.core.files.uploadedfile.SimpleUploadedFile'> 807 805 808 >>> type(f.clean(SimpleUploadedFile('name', 'Some File Content'), 'files/test4.pdf')) 806 809 <class 'django.core.files.uploadedfile.SimpleUploadedFile'> 807 810 -
tests/regressiontests/forms/forms.py
1480 1480 >>> f.is_valid() 1481 1481 True 1482 1482 1483 >>> f = FileForm(data={}, files={'file1': SimpleUploadedFile('我隻氣墊船裝滿晒鱔.txt', 'मेरी मँडराने वाली नाव सर्पमीनों से भरी ह')}, auto_id=False) 1484 >>> print f 1485 <tr><th>File1:</th><td><input type="file" name="file1" /></td></tr> 1486 1483 1487 # Basic form processing in a view ############################################# 1484 1488 1485 1489 >>> from django.template import Template, Context