Ticket #26459: 0001-tests-format-float-to-Decimal-with-proper-rounding.patch

File 0001-tests-format-float-to-Decimal-with-proper-rounding.patch, 1.1 KB (added by yasondinalt, 9 years ago)

Tests

  • tests/model_fields/test_decimalfield.py

    From 1873c0e51918ac7d8904ccdfa3f9aec85a11753a Mon Sep 17 00:00:00 2001
    From: yasondinalt <yason.bad@gmail.com>
    Date: Mon, 4 Apr 2016 20:37:51 +0300
    Subject: [PATCH] tests: format float to Decimal with proper rounding
    
    ---
     tests/model_fields/test_decimalfield.py | 4 +++-
     1 file changed, 3 insertions(+), 1 deletion(-)
    
    diff --git a/tests/model_fields/test_decimalfield.py b/tests/model_fields/test_decimalfield.py
    index af9bd6c..fb00b7c 100644
    a b class DecimalFieldTests(TestCase):  
    2525        f = models.DecimalField(max_digits=5, decimal_places=1)
    2626        self.assertEqual(f._format(f.to_python(2)), '2.0')
    2727        self.assertEqual(f._format(f.to_python('2.6')), '2.6')
     28        self.assertEqual(f._format(f.to_python(2.15)), '2.2')
     29        self.assertEqual(f._format(f.to_python(2.25)), '2.3')
    2830        self.assertEqual(f._format(None), None)
    2931
    3032    def test_get_db_prep_lookup(self):
    3133        f = models.DecimalField(max_digits=5, decimal_places=1)
    3234        self.assertEqual(f.get_db_prep_lookup('exact', None, connection=connection), [None])
Back to Top