Ticket #17854: test_ticket17854.patch

File test_ticket17854.patch, 1.4 KB (added by Taylor Mitchell, 13 years ago)

Test illustrating behavior

  • tests/regressiontests/model_fields/models.py

    diff --git a/tests/regressiontests/model_fields/models.py b/tests/regressiontests/model_fields/models.py
    index 4dcfb17..532cdd5 100644
    a b class Whiz(models.Model):  
    4747
    4848class BigD(models.Model):
    4949    d = models.DecimalField(max_digits=38, decimal_places=30)
     50    d2 = models.DecimalField(max_digits=200, decimal_places=100, null=True)
    5051
    5152class BigS(models.Model):
    5253    s = models.SlugField(max_length=255)
  • tests/regressiontests/model_fields/tests.py

    diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
    index 8fe67fb..3c1dee0 100644
    a b class DecimalFieldTests(test.TestCase):  
    112112        # This should not crash. That counts as a win for our purposes.
    113113        Foo.objects.filter(d__gte=100000000000)
    114114
     115    def test_save_large_values(self):
     116        values = (
     117            "987654321001234.987654321001234",
     118        )
     119        for v in values:
     120            bd = BigD(d=0, d2=v)
     121            bd.save()
     122            bd = BigD.objects.get(pk=bd.pk)
     123            self.assertEqual(bd.d2, Decimal(v))
     124
    115125class ForeignKeyTests(test.TestCase):
    116126    def test_callable_default(self):
    117127        """Test the use of a lazy callable for ForeignKey.default"""
Back to Top