Ticket #8556: 8556-tests.diff
File 8556-tests.diff, 1.2 KB (added by , 16 years ago) |
---|
-
tests/modeltests/model_forms/models.py
98 98 def __unicode__(self): 99 99 return self.description 100 100 101 class CommaSeparatedInteger(models.Model): 102 field = models.CommaSeparatedIntegerField(max_length=20) 103 104 def __unicode__(self): 105 return self.field 106 101 107 __test__ = {'API_TESTS': """ 102 108 >>> from django import forms 103 109 >>> from django.forms.models import ModelForm, model_to_dict … … 1050 1056 <link href="/some/form/css" type="text/css" media="all" rel="stylesheet" /> 1051 1057 <script type="text/javascript" src="/some/form/javascript"></script> 1052 1058 1059 >>> class CommaSeparatedIntegerForm(ModelForm): 1060 ... class Meta: 1061 ... model = CommaSeparatedInteger 1062 1063 >>> f = CommaSeparatedIntegerForm().fields['field'] 1064 >>> f.clean('1,2,3') 1065 u'1,2,3' 1066 >>> f.clean('1a,2') 1067 Traceback (most recent call last): 1068 ... 1069 ValidationError: [u'Enter a valid value.'] 1070 >>> f.clean(',,,,') 1071 u',,,,' 1072 >>> f.clean('1.2') 1073 Traceback (most recent call last): 1074 ... 1075 ValidationError: [u'Enter a valid value.'] 1076 >>> f.clean('1,,2') 1077 u'1,,2' 1078 >>> f.clean('1') 1079 u'1' 1080 1053 1081 """}