Changeset 7979 for django/branches/gis/tests
- Timestamp:
- 07/19/08 08:30:47 (6 months ago)
- Files:
-
- django/branches/gis (modified) (1 prop)
- django/branches/gis/tests/modeltests/fixtures/models.py (modified) (1 diff)
- django/branches/gis/tests/modeltests/invalid_models/models.py (modified) (2 diffs)
- django/branches/gis/tests/modeltests/lookup/models.py (modified) (1 diff)
- django/branches/gis/tests/modeltests/many_to_one/models.py (modified) (1 diff)
- django/branches/gis/tests/modeltests/model_formsets (copied) (copied from django/trunk/tests/modeltests/model_formsets)
- django/branches/gis/tests/modeltests/model_formsets/__init__.py (copied) (copied from django/trunk/tests/modeltests/model_formsets/__init__.py)
- django/branches/gis/tests/modeltests/model_formsets/models.py (copied) (copied from django/trunk/tests/modeltests/model_formsets/models.py)
- django/branches/gis/tests/modeltests/model_forms/models.py (modified) (5 diffs)
- django/branches/gis/tests/modeltests/test_client/views.py (modified) (1 diff)
- django/branches/gis/tests/modeltests/transactions/models.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/admin_ordering (copied) (copied from django/trunk/tests/regressiontests/admin_ordering)
- django/branches/gis/tests/regressiontests/admin_ordering/__init__.py (copied) (copied from django/trunk/tests/regressiontests/admin_ordering/__init__.py)
- django/branches/gis/tests/regressiontests/admin_ordering/models.py (copied) (copied from django/trunk/tests/regressiontests/admin_ordering/models.py)
- django/branches/gis/tests/regressiontests/admin_scripts/tests.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/admin_views (copied) (copied from django/trunk/tests/regressiontests/admin_views)
- django/branches/gis/tests/regressiontests/admin_views/fixtures (copied) (copied from django/trunk/tests/regressiontests/admin_views/fixtures)
- django/branches/gis/tests/regressiontests/admin_views/fixtures/admin-views-users.xml (copied) (copied from django/trunk/tests/regressiontests/admin_views/fixtures/admin-views-users.xml)
- django/branches/gis/tests/regressiontests/admin_views/fixtures/string-primary-key.xml (copied) (copied from django/trunk/tests/regressiontests/admin_views/fixtures/string-primary-key.xml)
- django/branches/gis/tests/regressiontests/admin_views/__init__.py (copied) (copied from django/trunk/tests/regressiontests/admin_views/__init__.py)
- django/branches/gis/tests/regressiontests/admin_views/models.py (copied) (copied from django/trunk/tests/regressiontests/admin_views/models.py)
- django/branches/gis/tests/regressiontests/admin_views/tests.py (copied) (copied from django/trunk/tests/regressiontests/admin_views/tests.py)
- django/branches/gis/tests/regressiontests/admin_views/urls.py (copied) (copied from django/trunk/tests/regressiontests/admin_views/urls.py)
- django/branches/gis/tests/regressiontests/admin_widgets (copied) (copied from django/trunk/tests/regressiontests/admin_widgets)
- django/branches/gis/tests/regressiontests/admin_widgets/__init__.py (copied) (copied from django/trunk/tests/regressiontests/admin_widgets/__init__.py)
- django/branches/gis/tests/regressiontests/admin_widgets/models.py (copied) (copied from django/trunk/tests/regressiontests/admin_widgets/models.py)
- django/branches/gis/tests/regressiontests/datetime_safe (copied) (copied from django/trunk/tests/regressiontests/datetime_safe)
- django/branches/gis/tests/regressiontests/datetime_safe/__init__.py (copied) (copied from django/trunk/tests/regressiontests/datetime_safe/__init__.py)
- django/branches/gis/tests/regressiontests/datetime_safe/models.py (copied) (copied from django/trunk/tests/regressiontests/datetime_safe/models.py)
- django/branches/gis/tests/regressiontests/datetime_safe/tests.py (copied) (copied from django/trunk/tests/regressiontests/datetime_safe/tests.py)
- django/branches/gis/tests/regressiontests/forms/error_messages.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/forms/extra.py (modified) (3 diffs)
- django/branches/gis/tests/regressiontests/forms/fields.py (modified) (10 diffs)
- django/branches/gis/tests/regressiontests/forms/formsets.py (copied) (copied from django/trunk/tests/regressiontests/forms/formsets.py)
- django/branches/gis/tests/regressiontests/forms/forms.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/forms/media.py (copied) (copied from django/trunk/tests/regressiontests/forms/media.py)
- django/branches/gis/tests/regressiontests/forms/models.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/forms/regressions.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/forms/tests.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/forms/util.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/forms/widgets.py (modified) (8 diffs)
- django/branches/gis/tests/regressiontests/inline_formsets (copied) (copied from django/trunk/tests/regressiontests/inline_formsets)
- django/branches/gis/tests/regressiontests/inline_formsets/__init__.py (copied) (copied from django/trunk/tests/regressiontests/inline_formsets/__init__.py)
- django/branches/gis/tests/regressiontests/inline_formsets/models.py (copied) (copied from django/trunk/tests/regressiontests/inline_formsets/models.py)
- django/branches/gis/tests/regressiontests/invalid_admin_options (deleted)
- django/branches/gis/tests/regressiontests/mail (copied) (copied from django/trunk/tests/regressiontests/mail)
- django/branches/gis/tests/regressiontests/mail/__init__.py (copied) (copied from django/trunk/tests/regressiontests/mail/__init__.py)
- django/branches/gis/tests/regressiontests/mail/models.py (copied) (copied from django/trunk/tests/regressiontests/mail/models.py)
- django/branches/gis/tests/regressiontests/mail/tests.py (copied) (copied from django/trunk/tests/regressiontests/mail/tests.py)
- django/branches/gis/tests/regressiontests/modeladmin (copied) (copied from django/trunk/tests/regressiontests/modeladmin)
- django/branches/gis/tests/regressiontests/modeladmin/__init__.py (copied) (copied from django/trunk/tests/regressiontests/modeladmin/__init__.py)
- django/branches/gis/tests/regressiontests/modeladmin/models.py (copied) (copied from django/trunk/tests/regressiontests/modeladmin/models.py)
- django/branches/gis/tests/regressiontests/queries/models.py (modified) (4 diffs)
- django/branches/gis/tests/regressiontests/views/fixtures/testdata.json (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/views/models.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/views/tests/generic/create_update.py (copied) (copied from django/trunk/tests/regressiontests/views/tests/generic/create_update.py)
- django/branches/gis/tests/regressiontests/views/tests/__init__.py (modified) (1 diff)
- django/branches/gis/tests/regressiontests/views/urls.py (modified) (2 diffs)
- django/branches/gis/tests/regressiontests/views/views.py (modified) (1 diff)
- django/branches/gis/tests/templates/custom_admin (copied) (copied from django/trunk/tests/templates/custom_admin)
- django/branches/gis/tests/templates/custom_admin/change_form.html (copied) (copied from django/trunk/tests/templates/custom_admin/change_form.html)
- django/branches/gis/tests/templates/custom_admin/change_list.html (copied) (copied from django/trunk/tests/templates/custom_admin/change_list.html)
- django/branches/gis/tests/templates/custom_admin/delete_confirmation.html (copied) (copied from django/trunk/tests/templates/custom_admin/delete_confirmation.html)
- django/branches/gis/tests/templates/custom_admin/index.html (copied) (copied from django/trunk/tests/templates/custom_admin/index.html)
- django/branches/gis/tests/templates/custom_admin/login.html (copied) (copied from django/trunk/tests/templates/custom_admin/login.html)
- django/branches/gis/tests/templates/custom_admin/object_history.html (copied) (copied from django/trunk/tests/templates/custom_admin/object_history.html)
- django/branches/gis/tests/templates/views/article_confirm_delete.html (copied) (copied from django/trunk/tests/templates/views/article_confirm_delete.html)
- django/branches/gis/tests/templates/views/article_detail.html (modified) (1 diff)
- django/branches/gis/tests/templates/views/article_form.html (copied) (copied from django/trunk/tests/templates/views/article_form.html)
- django/branches/gis/tests/templates/views/urlarticle_detail.html (copied) (copied from django/trunk/tests/templates/views/urlarticle_detail.html)
- django/branches/gis/tests/templates/views/urlarticle_form.html (copied) (copied from django/trunk/tests/templates/views/urlarticle_form.html)
- django/branches/gis/tests/urls.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/gis
- Property svnmerge-integrated changed from /django/trunk:1-7917 to /django/trunk:1-7978
django/branches/gis/tests/modeltests/fixtures/models.py
r6394 r7979 59 59 # Database flushing does not work on MySQL with the default storage engine 60 60 # because it requires transaction support. 61 if settings.DATABASE_ENGINE not in ('mysql', 'mysql_old'):61 if settings.DATABASE_ENGINE != 'mysql': 62 62 __test__['API_TESTS'] += \ 63 63 """ django/branches/gis/tests/modeltests/invalid_models/models.py
r6920 r7979 6 6 7 7 from django.db import models 8 8 model_errors = "" 9 9 class FieldErrors(models.Model): 10 10 charfield = models.CharField() 11 11 decimalfield = models.DecimalField() 12 12 filefield = models.FileField() 13 prepopulate = models.CharField(max_length=10, prepopulate_from='bad')14 13 choices = models.CharField(max_length=10, choices='bad') 15 14 choices2 = models.CharField(max_length=10, choices=[(1,2,3),(1,2,3)]) … … 117 116 invalid_models.fielderrors: "decimalfield": DecimalFields require a "max_digits" attribute. 118 117 invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute. 119 invalid_models.fielderrors: "prepopulate": prepopulate_from should be a list or tuple.120 118 invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list). 121 119 invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples. django/branches/gis/tests/modeltests/lookup/models.py
r7482 r7979 381 381 382 382 383 if settings.DATABASE_ENGINE not in ('mysql', 'mysql_old'):383 if settings.DATABASE_ENGINE != 'mysql': 384 384 __test__['API_TESTS'] += r""" 385 385 # grouping and backreferences django/branches/gis/tests/modeltests/many_to_one/models.py
r7642 r7979 156 156 157 157 # And should work fine with the unicode that comes out of 158 # newforms.Form.cleaned_data158 # forms.Form.cleaned_data 159 159 >>> Article.objects.filter(reporter__first_name__exact='John').extra(where=["many_to_one_reporter.last_name='%s'" % u'Smith']) 160 160 [<Article: John's second story>, <Article: This is a test>] django/branches/gis/tests/modeltests/model_forms/models.py
r7918 r7979 80 80 81 81 __test__ = {'API_TESTS': """ 82 >>> from django import newforms asforms83 >>> from django. newforms.models import ModelForm82 >>> from django import forms 83 >>> from django.forms.models import ModelForm 84 84 >>> from django.core.files.uploadedfile import SimpleUploadedFile 85 85 … … 114 114 115 115 >>> CategoryForm.base_fields['url'].__class__ 116 <class 'django. newforms.fields.BooleanField'>116 <class 'django.forms.fields.BooleanField'> 117 117 118 118 … … 212 212 # Old form_for_x tests ####################################################### 213 213 214 >>> from django. newforms import ModelForm, CharField214 >>> from django.forms import ModelForm, CharField 215 215 >>> import datetime 216 216 … … 606 606 # ModelChoiceField ############################################################ 607 607 608 >>> from django. newforms import ModelChoiceField, ModelMultipleChoiceField608 >>> from django.forms import ModelChoiceField, ModelMultipleChoiceField 609 609 610 610 >>> f = ModelChoiceField(Category.objects.all()) … … 993 993 >>> instance.delete() 994 994 995 # Media on a ModelForm ######################################################## 996 997 # Similar to a regular Form class you can define custom media to be used on 998 # the ModelForm. 999 1000 >>> class ModelFormWithMedia(ModelForm): 1001 ... class Media: 1002 ... js = ('/some/form/javascript',) 1003 ... css = { 1004 ... 'all': ('/some/form/css',) 1005 ... } 1006 ... class Meta: 1007 ... model = PhoneNumber 1008 >>> f = ModelFormWithMedia() 1009 >>> print f.media 1010 <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" /> 1011 <script type="text/javascript" src="/some/form/javascript"></script> 1012 995 1013 """} django/branches/gis/tests/modeltests/test_client/views.py
r7918 r7979 5 5 from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound 6 6 from django.contrib.auth.decorators import login_required, permission_required 7 from django. newforms.forms import Form8 from django. newforms import fields7 from django.forms.forms import Form 8 from django.forms import fields 9 9 from django.shortcuts import render_to_response 10 10 django/branches/gis/tests/modeltests/transactions/models.py
r7482 r7979 26 26 building_docs = getattr(settings, 'BUILDING_DOCS', False) 27 27 28 if building_docs or settings.DATABASE_ENGINE not in ('mysql', 'mysql_old'):28 if building_docs or settings.DATABASE_ENGINE != 'mysql': 29 29 __test__['API_TESTS'] += """ 30 30 # the default behavior is to autocommit after each save() action django/branches/gis/tests/regressiontests/admin_scripts/tests.py
r7918 r7979 54 54 # Build the command line 55 55 cmd = 'python "%s"' % script 56 cmd += ''.join( ' %s' % arg for arg in args)56 cmd += ''.join([' %s' % arg for arg in args]) 57 57 58 58 # Remember the old environment … … 109 109 def assertOutput(self, stream, msg): 110 110 "Utility assertion: assert that the given message exists in the output" 111 self. assertTrue(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream))111 self.failUnless(msg in stream, "'%s' does not match actual output text '%s'" % (msg, stream)) 112 112 113 113 ########################################################################## django/branches/gis/tests/regressiontests/forms/error_messages.py
r7836 r7979 1 1 # -*- coding: utf-8 -*- 2 2 tests = r""" 3 >>> from django. newforms import *3 >>> from django.forms import * 4 4 >>> from django.core.files.uploadedfile import SimpleUploadedFile 5 5 django/branches/gis/tests/regressiontests/forms/extra.py
r7354 r7979 1 1 # -*- coding: utf-8 -*- 2 2 tests = r""" 3 >>> from django. newforms import *3 >>> from django.forms import * 4 4 >>> from django.utils.encoding import force_unicode 5 5 >>> import datetime … … 15 15 ############### 16 16 17 The newforms library comes with some extra, higher-level Field and Widget17 The forms library comes with some extra, higher-level Field and Widget 18 18 classes that demonstrate some of the library's abilities. 19 19 20 20 # SelectDateWidget ############################################################ 21 21 22 >>> from django. newforms.extras import SelectDateWidget22 >>> from django.forms.extras import SelectDateWidget 23 23 >>> w = SelectDateWidget(years=('2007','2008','2009','2010','2011','2012','2013','2014','2015','2016')) 24 24 >>> print w.render('mydate', '') … … 425 425 ####################################### 426 426 427 >>> from django. newforms.util import ErrorList427 >>> from django.forms.util import ErrorList 428 428 >>> class DivErrorList(ErrorList): 429 429 ... def __unicode__(self): django/branches/gis/tests/regressiontests/forms/fields.py
r7918 r7979 1 1 # -*- coding: utf-8 -*- 2 2 tests = r""" 3 >>> from django. newforms import *4 >>> from django. newforms.widgets import RadioFieldRenderer3 >>> from django.forms import * 4 >>> from django.forms.widgets import RadioFieldRenderer 5 5 >>> from django.core.files.uploadedfile import SimpleUploadedFile 6 6 >>> import datetime … … 18 18 19 19 Each Field class does some sort of validation. Each Field has a clean() method, 20 which either raises django. newforms.ValidationError or returns the "clean"20 which either raises django.forms.ValidationError or returns the "clean" 21 21 data -- usually a Unicode object, but, in some rare cases, a list. 22 22 … … 981 981 # ChoiceField ################################################################# 982 982 983 >>> f = ChoiceField(choices=[('1', ' 1'), ('2', '2')])983 >>> f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')]) 984 984 >>> f.clean('') 985 985 Traceback (most recent call last): … … 997 997 Traceback (most recent call last): 998 998 ... 999 ValidationError: [u'Select a valid choice. That choiceis not one of the available choices.']1000 1001 >>> f = ChoiceField(choices=[('1', ' 1'), ('2', '2')], required=False)999 ValidationError: [u'Select a valid choice. 3 is not one of the available choices.'] 1000 1001 >>> f = ChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False) 1002 1002 >>> f.clean('') 1003 1003 u'' … … 1011 1011 Traceback (most recent call last): 1012 1012 ... 1013 ValidationError: [u'Select a valid choice. That choiceis not one of the available choices.']1013 ValidationError: [u'Select a valid choice. 3 is not one of the available choices.'] 1014 1014 1015 1015 >>> f = ChoiceField(choices=[('J', 'John'), ('P', 'Paul')]) … … 1019 1019 Traceback (most recent call last): 1020 1020 ... 1021 ValidationError: [u'Select a valid choice. That choice is not one of the available choices.'] 1021 ValidationError: [u'Select a valid choice. John is not one of the available choices.'] 1022 1023 >>> f = ChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')]) 1024 >>> f.clean(1) 1025 u'1' 1026 >>> f.clean('1') 1027 u'1' 1028 >>> f.clean(3) 1029 u'3' 1030 >>> f.clean('3') 1031 u'3' 1032 >>> f.clean(5) 1033 u'5' 1034 >>> f.clean('5') 1035 u'5' 1036 >>> f.clean('6') 1037 Traceback (most recent call last): 1038 ... 1039 ValidationError: [u'Select a valid choice. 6 is not one of the available choices.'] 1022 1040 1023 1041 # NullBooleanField ############################################################ … … 1037 1055 # MultipleChoiceField ######################################################### 1038 1056 1039 >>> f = MultipleChoiceField(choices=[('1', ' 1'), ('2', '2')])1057 >>> f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')]) 1040 1058 >>> f.clean('') 1041 1059 Traceback (most recent call last): … … 1073 1091 ValidationError: [u'Select a valid choice. 3 is not one of the available choices.'] 1074 1092 1075 >>> f = MultipleChoiceField(choices=[('1', ' 1'), ('2', '2')], required=False)1093 >>> f = MultipleChoiceField(choices=[('1', 'One'), ('2', 'Two')], required=False) 1076 1094 >>> f.clean('') 1077 1095 [] … … 1101 1119 ValidationError: [u'Select a valid choice. 3 is not one of the available choices.'] 1102 1120 1121 >>> f = MultipleChoiceField(choices=[('Numbers', (('1', 'One'), ('2', 'Two'))), ('Letters', (('3','A'),('4','B'))), ('5','Other')]) 1122 >>> f.clean([1]) 1123 [u'1'] 1124 >>> f.clean(['1']) 1125 [u'1'] 1126 >>> f.clean([1, 5]) 1127 [u'1', u'5'] 1128 >>> f.clean([1, '5']) 1129 [u'1', u'5'] 1130 >>> f.clean(['1', 5]) 1131 [u'1', u'5'] 1132 >>> f.clean(['1', '5']) 1133 [u'1', u'5'] 1134 >>> f.clean(['6']) 1135 Traceback (most recent call last): 1136 ... 1137 ValidationError: [u'Select a valid choice. 6 is not one of the available choices.'] 1138 >>> f.clean(['1','6']) 1139 Traceback (most recent call last): 1140 ... 1141 ValidationError: [u'Select a valid choice. 6 is not one of the available choices.'] 1142 1143 1103 1144 # ComboField ################################################################## 1104 1145 … … 1154 1195 ... 1155 1196 >>> import os 1156 >>> from django import newforms asforms1197 >>> from django import forms 1157 1198 >>> path = forms.__file__ 1158 1199 >>> path = os.path.dirname(path) + '/' 1159 1200 >>> fix_os_paths(path) 1160 '.../django/ newforms/'1201 '.../django/forms/' 1161 1202 >>> f = forms.FilePathField(path=path) 1162 1203 >>> f.choices.sort() 1163 1204 >>> fix_os_paths(f.choices) 1164 [('.../django/ newforms/__init__.py', '__init__.py'), ('.../django/newforms/__init__.pyc', '__init__.pyc'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/fields.pyc', 'fields.pyc'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/forms.pyc', 'forms.pyc'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/models.pyc', 'models.pyc'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/util.pyc', 'util.pyc'), ('.../django/newforms/widgets.py', 'widgets.py'), ('.../django/newforms/widgets.pyc', 'widgets.pyc')]1205 [('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/__init__.pyc', '__init__.pyc'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/fields.pyc', 'fields.pyc'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/forms.pyc', 'forms.pyc'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/models.pyc', 'models.pyc'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/util.pyc', 'util.pyc'), ('.../django/forms/widgets.py', 'widgets.py'), ('.../django/forms/widgets.pyc', 'widgets.pyc')] 1165 1206 >>> f.clean('fields.py') 1166 1207 Traceback (most recent call last): 1167 1208 ... 1168 ValidationError: [u'Select a valid choice. That choiceis not one of the available choices.']1209 ValidationError: [u'Select a valid choice. fields.py is not one of the available choices.'] 1169 1210 >>> fix_os_paths(f.clean(path + 'fields.py')) 1170 u'.../django/ newforms/fields.py'1211 u'.../django/forms/fields.py' 1171 1212 >>> f = forms.FilePathField(path=path, match='^.*?\.py$') 1172 1213 >>> f.choices.sort() 1173 1214 >>> fix_os_paths(f.choices) 1174 [('.../django/ newforms/__init__.py', '__init__.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')]1215 [('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/widgets.py', 'widgets.py')] 1175 1216 >>> f = forms.FilePathField(path=path, recursive=True, match='^.*?\.py$') 1176 1217 >>> f.choices.sort() 1177 1218 >>> fix_os_paths(f.choices) 1178 [('.../django/ newforms/__init__.py', '__init__.py'), ('.../django/newforms/extras/__init__.py', 'extras/__init__.py'), ('.../django/newforms/extras/widgets.py', 'extras/widgets.py'), ('.../django/newforms/fields.py', 'fields.py'), ('.../django/newforms/forms.py', 'forms.py'), ('.../django/newforms/models.py', 'models.py'), ('.../django/newforms/util.py', 'util.py'), ('.../django/newforms/widgets.py', 'widgets.py')]1219 [('.../django/forms/__init__.py', '__init__.py'), ('.../django/forms/extras/__init__.py', 'extras/__init__.py'), ('.../django/forms/extras/widgets.py', 'extras/widgets.py'), ('.../django/forms/fields.py', 'fields.py'), ('.../django/forms/forms.py', 'forms.py'), ('.../django/forms/models.py', 'models.py'), ('.../django/forms/util.py', 'util.py'), ('.../django/forms/widgets.py', 'widgets.py')] 1179 1220 1180 1221 # SplitDateTimeField ########################################################## django/branches/gis/tests/regressiontests/forms/forms.py
r7836 r7979 1 1 # -*- coding: utf-8 -*- 2 2 tests = r""" 3 >>> from django. newforms import *3 >>> from django.forms import * 4 4 >>> from django.core.files.uploadedfile import SimpleUploadedFile 5 5 >>> import datetime … … 1668 1668 <input type="submit" /> 1669 1669 </form> 1670 1671 1672 # The empty_permitted attribute ############################################## 1673 1674 Sometimes (pretty much in formsets) we want to allow a form to pass validation 1675 if it is completely empty. We can accomplish this by using the empty_permitted 1676 agrument to a form constructor. 1677 1678 >>> class SongForm(Form): 1679 ... artist = CharField() 1680 ... name = CharField() 1681 1682 First let's show what happens id empty_permitted=False (the default): 1683 1684 >>> data = {'artist': '', 'song': ''} 1685 1686 >>> form = SongForm(data, empty_permitted=False) 1687 >>> form.is_valid() 1688 False 1689 >>> form.errors 1690 {'name': [u'This field is required.'], 'artist': [u'This field is required.']} 1691 >>> form.cleaned_data 1692 Traceback (most recent call last): 1693 ... 1694 AttributeError: 'SongForm' object has no attribute 'cleaned_data' 1695 1696 1697 Now let's show what happens when empty_permitted=True and the form is empty. 1698 1699 >>> form = SongForm(data, empty_permitted=True) 1700 >>> form.is_valid() 1701 True 1702 >>> form.errors 1703 {} 1704 >>> form.cleaned_data 1705 {} 1706 1707 But if we fill in data for one of the fields, the form is no longer empty and 1708 the whole thing must pass validation. 1709 1710 >>> data = {'artist': 'The Doors', 'song': ''} 1711 >>> form = SongForm(data, empty_permitted=False) 1712 >>> form.is_valid() 1713 False 1714 >>> form.errors 1715 {'name': [u'This field is required.']} 1716 >>> form.cleaned_data 1717 Traceback (most recent call last): 1718 ... 1719 AttributeError: 'SongForm' object has no attribute 'cleaned_data' 1720 1721 If a field is not given in the data then None is returned for its data. Lets 1722 make sure that when checking for empty_permitted that None is treated 1723 accordingly. 1724 1725 >>> data = {'artist': None, 'song': ''} 1726 >>> form = SongForm(data, empty_permitted=True) 1727 >>> form.is_valid() 1728 True 1729 1730 However, we *really* need to be sure we are checking for None as any data in 1731 initial that returns False on a boolean call needs to be treated literally. 1732 1733 >>> class PriceForm(Form): 1734 ... amount = FloatField() 1735 ... qty = IntegerField() 1736 1737 >>> data = {'amount': '0.0', 'qty': ''} 1738 >>> form = PriceForm(data, initial={'amount': 0.0}, empty_permitted=True) 1739 >>> form.is_valid() 1740 True 1741 1670 1742 """ django/branches/gis/tests/regressiontests/forms/models.py
r6815 r7979 16 16 17 17 __test__ = {'API_TESTS': """ 18 >>> from django. newforms import form_for_model, form_for_instance18 >>> from django.forms import form_for_model, form_for_instance 19 19 20 20 # Boundary conditions on a PostitiveIntegerField ######################### django/branches/gis/tests/regressiontests/forms/regressions.py
r7768 r7979 4 4 tests = r""" 5 5 It should be possible to re-use attribute dictionaries (#3810) 6 >>> from django. newforms import *6 >>> from django.forms import * 7 7 >>> extra_attrs = {'class': 'special'} 8 8 >>> class TestForm(Form): django/branches/gis/tests/regressiontests/forms/tests.py
r6920 r7979 27 27 from util import tests as util_tests 28 28 from widgets import tests as widgets_tests 29 from formsets import tests as formset_tests 30 from media import media_tests 29 31 30 32 __test__ = { … … 54 56 'localflavor_za_tests': localflavor_za_tests, 55 57 'regression_tests': regression_tests, 58 'formset_tests': formset_tests, 59 'media_tests': media_tests, 56 60 'util_tests': util_tests, 57 61 'widgets_tests': widgets_tests, django/branches/gis/tests/regressiontests/forms/util.py
r7354 r7979 1 1 # coding: utf-8 2 2 """ 3 Tests for newforms/util.py module.3 Tests for forms/util.py module. 4 4 """ 5 5 6 6 tests = r""" 7 >>> from django. newforms.util import *7 >>> from django.forms.util import * 8 8 >>> from django.utils.translation import ugettext_lazy 9 9 … … 12 12 ########### 13 13 14 >>> from django. newforms.util import flatatt14 >>> from django.forms.util import flatatt 15 15 >>> flatatt({'id': "header"}) 16 16 u' id="header"' django/branches/gis/tests/regressiontests/forms/widgets.py
r7768 r7979 1 1 # -*- coding: utf-8 -*- 2 2 tests = r""" 3 >>> from django. newforms import *4 >>> from django. newforms.widgets import RadioFieldRenderer3 >>> from django.forms import * 4 >>> from django.forms.widgets import RadioFieldRenderer 5 5 >>> from django.utils.safestring import mark_safe 6 6 >>> import datetime … … 203 203 u'<input type="file" class="fun" name="email" />' 204 204 205 Test for the behavior of _has_changed for FileInput. The value of data will 206 more than likely come from request.FILES. The value of initial data will 207 likely be a filename stored in the database. Since its value is of no use to 208 a FileInput it is ignored. 209 210 >>> w = FileInput() 211 212 # No file was uploaded and no initial data. 213 >>> w._has_changed(u'', None) 214 False 215 216 # A file was uploaded and no initial data. 217 >>> w._has_changed(u'', {'filename': 'resume.txt', 'content': 'My resume'}) 218 True 219 220 # A file was not uploaded, but there is initial data 221 >>> w._has_changed(u'resume.txt', None) 222 False 223 224 # A file was uploaded and there is initial data (file identity is not dealt 225 # with here) 226 >>> w._has_changed('resume.txt', {'filename': 'resume.txt', 'content': 'My resume'}) 227 True 228 205 229 # Textarea Widget ############################################################# 206 230 … … 293 317 False 294 318 319 >>> w._has_changed(None, None) 320 False 321 >>> w._has_changed(None, u'') 322 False 323 >>> w._has_changed(u'', None) 324 False 325 >>> w._has_changed(u'', u'') 326 False 327 >>> w._has_changed(False, u'on') 328 True 329 >>> w._has_changed(True, u'on') 330 False 331 >>> w._has_changed(True, u'') 332 True 333 295 334 # Select Widget ############################################################### 296 335 … … 420 459 </select> 421 460 461 Choices can be nested one level in order to create HTML optgroups: 462 >>> w.choices=(('outer1', 'Outer 1'), ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2')))) 463 >>> print w.render('nestchoice', None) 464 <select name="nestchoice"> 465 <option value="outer1">Outer 1</option> 466 <optgroup label="Group "1""> 467 <option value="inner1">Inner 1</option> 468 <option value="inner2">Inner 2</option> 469 </optgroup> 470 </select> 471 472 >>> print w.render('nestchoice', 'outer1') 473 <select name="nestchoice"> 474 <option value="outer1" selected="selected">Outer 1</option> 475 <optgroup label="Group "1""> 476 <option value="inner1">Inner 1</option> 477 <option value="inner2">Inner 2</option> 478 </optgroup> 479 </select> 480 481 >>> print w.render('nestchoice', 'inner1') 482 <select name="nestchoice"> 483 <option value="outer1">Outer 1</option> 484 <optgroup label="Group "1""> 485 <option value="inner1" selected="selected">Inner 1</option> 486 <option value="inner2">Inner 2</option> 487 </optgroup> 488 </select> 489 422 490 # NullBooleanSelect Widget #################################################### 423 491 … … 573 641 >>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) 574 642 u'<select multiple="multiple" name="nums">\n<option value="1">1</option>\n<option value="2">2</option>\n<option value="3">3</option>\n<option value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" selected="selected">\u0160\u0110abc\u0106\u017d\u0107\u017e\u0161\u0111</option>\n<option value="\u0107\u017e\u0161\u0111">abc\u0107\u017e\u0161\u0111</option>\n</select>' 643 644 # Test the usage of _has_changed 645 >>> w._has_changed(None, None) 646 False 647 >>> w._has_changed([], None) 648 False 649 >>> w._has_changed(None, [u'1']) 650 True 651 >>> w._has_changed([1, 2], [u'1', u'2']) 652 False 653 >>> w._has_changed([1, 2], [u'1']) 654 True 655 >>> w._has_changed([1, 2], [u'1', u'3']) 656 True 657 658 # Choices can be nested one level in order to create HTML optgroups: 659 >>> w.choices = (('outer1', 'Outer 1'), ('Group "1"', (('inner1', 'Inner 1'), ('inner2', 'Inner 2')))) 660 >>> print w.render('nestchoice', None) 661 <select multiple="multiple" name="nestchoice"> 662 <option value="outer1">Outer 1</option> 663 <optgroup label="Group "1""> 664 <option value="inner1">Inner 1</option> 665 <option value="inner2">Inner 2</option> 666 </optgroup> 667 </select> 668 669 >>> print w.render('nestchoice', ['outer1']) 670 <select multiple="multiple" name="nestchoice"> 671 <option value="outer1" selected="selected">Outer 1</option> 672 <optgroup label="Group "1""> 673 <option value="inner1">Inner 1</option> 674 <option value="inner2">Inner 2</option> 675 </optgroup> 676 </select> 677 678 >>> print w.render('nestchoice', ['inner1']) 679 <select multiple="multiple" name="nestchoice"> 680 <option value="outer1">Outer 1</option> 681 <optgroup label="Group "1""> 682 <option value="inner1" selected="selected">Inner 1</option> 683 <option value="inner2">Inner 2</option> 684 </optgroup> 685 </select> 686 687 >>> print w.render('nestchoice', ['outer1', 'inner2']) 688 <select multiple="multiple" name="nestchoice"> 689 <option value="outer1" selected="selected">Outer 1</option> 690 <optgroup label="Group "1""> 691 <option value="inner1">Inner 1</option> 692 <option value="inner2" selected="selected">Inner 2</option> 693 </optgroup> 694 </select> 575 695 576 696 # RadioSelect Widget ########################################################## … … 872 992 </ul> 873 993 994 # Test the usage of _has_changed 995 >>> w._has_changed(None, None) 996 False 997 >>> w._has_changed([], None) 998 False 999 >>> w._has_changed(None, [u'1']) 1000 True 1001 >>> w._has_changed([1, 2], [u'1', u'2']) 1002 False 1003 >>> w._has_changed([1, 2], [u'1']) 1004 True 1005 >>> w._has_changed([1, 2], [u'1', u'3']) 1006 True 1007 874 1008 # Unicode choices are correctly rendered as HTML 875 1009 >>> w.render('nums', ['ŠĐĆŽćžšđ'], choices=[('ŠĐĆŽćžšđ', 'ŠĐabcĆŽćžšđ'), ('ćžšđ', 'abcćžšđ')]) … … 896 1030 u'<input id="bar_0" type="text" class="big" value="john" name="name_0" /><br /><input id="bar_1" type="text" class="small" value="lennon" name="name_1" />' 897 1031 1032 >>> w = MyMultiWidget(widgets=(TextInput(), TextInput())) 1033 1034 # test with no initial data 1035 >>> w._has_changed(None, [u'john', u'lennon']) 1036 True 1037 1038 # test when the data is the same as initial 1039 >>> w._has_changed(u'john__lennon', [u'john', u'lennon']) 1040 False 1041 1042 # test when the first widget's data has changed 1043 >>> w._has_changed(u'john__lennon', [u'alfred', u'lennon']) 1044 True 1045 1046 # test when the last widget's data has changed. this ensures that it is not 1047 # short circuiting while testing the widgets. 1048 >>> w._has_changed(u'john__lennon', [u'john', u'denver']) 1049 True 1050 898 1051 # SplitDateTimeWidget ######################################################### 899 1052 … … 914
