Ticket #4287: 4287_tests.diff
File 4287_tests.diff, 1.4 KB (added by , 17 years ago) |
---|
-
tests/regressiontests/datatypes/models.py
17 17 class Meta: 18 18 ordering = ('consumed_at',) 19 19 20 def __ str__(self):20 def __unicode__(self): 21 21 return self.name 22 22 23 24 class FloatFieldModel(models.Model): 25 """#4287: Test model for storing inf, -inf, nan in a FloatField.""" 26 field = models.FloatField() 27 28 def __unicode__(self): 29 return unicode(self.field) 30 31 23 32 __test__ = {'API_TESTS': """ 24 33 # No donuts are in the system yet. 25 34 >>> Donut.objects.all() … … 56 65 datetime.time(5, 30) 57 66 >>> d3.consumed_at 58 67 datetime.datetime(2007, 4, 20, 16, 19, 59) 68 69 >>> import math 70 >>> f0 = FloatFieldModel(field=math.pi) 71 >>> f0.save() 72 73 >>> f1 = FloatFieldModel(field=float('inf')) 74 >>> f1.save() 75 76 >>> f2 = FloatFieldModel(field=float('-inf')) 77 >>> f2.save() 78 79 >>> f3 = FloatFieldModel(field=float('nan')) 80 >>> f3.save() 81 82 >>> FloatFieldModel.objects.all() 83 [<FloatFieldModel: 3.14159265359>, <FloatFieldModel: inf>, <FloatFieldModel: -inf>, <FloatFieldModel: nan>] 84 85 >>> FloatFieldModel.objects.order_by('field') 86 [<FloatFieldModel: -inf>, <FloatFieldModel: 3.14159265359>, <FloatFieldModel: inf>, <FloatFieldModel: nan>] 87 59 88 """}