summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-12-28 05:16:37 +0500
committerTim Graham <timograham@gmail.com>2017-12-27 19:16:37 -0500
commit44908d4d9360f72b9511aa0a878458285ba326d4 (patch)
tree3682f389feb5bee458f56638463db83556fff007 /tests
parentf1aa58479cdc6051dd2e97feca2d584c43aee1e7 (diff)
Fixed #28967 -- Prevented Cast to FloatField from rounding to integer on MySQL.
Diffstat (limited to 'tests')
-rw-r--r--tests/db_functions/test_cast.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/db_functions/test_cast.py b/tests/db_functions/test_cast.py
index 42bbce118e..36220cf640 100644
--- a/tests/db_functions/test_cast.py
+++ b/tests/db_functions/test_cast.py
@@ -1,4 +1,5 @@
import datetime
+import decimal
from django.db import models
from django.db.models.expressions import Value
@@ -55,5 +56,7 @@ class CastTests(TestCase):
self.assertEqual(dates.get().cast_datetime, now)
def test_cast_from_python(self):
- numbers = Author.objects.annotate(cast_float=Cast(0, models.FloatField()))
- self.assertEqual(numbers.get().cast_float, 0.0)
+ numbers = Author.objects.annotate(cast_float=Cast(decimal.Decimal(0.125), models.FloatField()))
+ cast_float = numbers.get().cast_float
+ self.assertIsInstance(cast_float, float)
+ self.assertEqual(cast_float, 0.125)