Ticket #6783: 6793_tests-svn-11368.diff
File 6793_tests-svn-11368.diff, 1.6 KB (added by , 15 years ago) |
---|
-
tests/regressiontests/model_regress/models.py
29 29 #5218: Test models with non-default primary keys / AutoFields 30 30 movie_id = models.AutoField(primary_key=True) 31 31 name = models.CharField(max_length=60) 32 rating = models.DecimalField(max_digits=6, decimal_places=3, default=2.5) 33 32 34 33 35 class Party(models.Model): 34 36 when = models.DateField(null=True) … … 165 167 >>> obj.save() 166 168 >>> Article.objects.filter(headline="A headline").update(pub_date=dt1) 167 169 1 170 """ 171 172 # Regression test for #6783 173 import locale 174 test_locale_available = False 175 try: 176 locale.setlocale(locale.LC_NUMERIC,'fr_FR') 177 test_locale_available = True 178 except: 179 pass 168 180 181 if test_locale_available: 182 __test__['LOCALE_TESTS'] = """ 183 # check for #6783 184 >>> from django.db.models.fields import DecimalField 185 >>> import locale 186 >>> pre_locale = locale.getlocale()[0] 187 >>> d = DecimalField(max_digits=6, decimal_places=3) 188 >>> locale.setlocale(locale.LC_NUMERIC,'fr_FR') 189 'fr_FR' 190 >>> print "%.1f" % 2.3 191 2.3 192 193 # locale is in effect, but print doesn't use it, and neither does DecimalField.format_number 194 >>> locale.format("%.1f",2.3) 195 '2,3' 196 >>> print d.format_number(3.456) 197 3.456 198 199 # we can safely save decimalfields into the DB even with the funky locale 200 >>> m = Movie(name = "Rambo", rating = 4.2) 201 >>> m.save() 202 >>> res = locale.setlocale(locale.LC_NUMERIC, pre_locale) 169 203 """ 170 204