Ticket #6783: 6793_tests-svn-11368.diff

File 6793_tests-svn-11368.diff, 1.6 KB (added by Dirk Datzert <dummy@…>, 15 years ago)

Tests against Django 1.1 trunk rev 11368

  • tests/regressiontests/model_regress/models.py

     
    2929    #5218: Test models with non-default primary keys / AutoFields
    3030    movie_id = models.AutoField(primary_key=True)
    3131    name = models.CharField(max_length=60)
     32    rating = models.DecimalField(max_digits=6, decimal_places=3, default=2.5)
     33   
    3234
    3335class Party(models.Model):
    3436    when = models.DateField(null=True)
     
    165167>>> obj.save()
    166168>>> Article.objects.filter(headline="A headline").update(pub_date=dt1)
    1671691
     170"""
     171 
     172# Regression test for #6783
     173import locale
     174test_locale_available  = False
     175try:
     176    locale.setlocale(locale.LC_NUMERIC,'fr_FR')
     177    test_locale_available  = True
     178except:
     179    pass
    168180
     181if 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
     1912.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)
     1973.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)
    169203"""
    170204
Back to Top