summaryrefslogtreecommitdiff
path: root/tests/db_functions/math/test_random.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/db_functions/math/test_random.py')
-rw-r--r--tests/db_functions/math/test_random.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/db_functions/math/test_random.py b/tests/db_functions/math/test_random.py
new file mode 100644
index 0000000000..6bcf49baf9
--- /dev/null
+++ b/tests/db_functions/math/test_random.py
@@ -0,0 +1,13 @@
+from django.db.models.functions import Random
+from django.test import TestCase
+
+from ..models import FloatModel
+
+
+class RandomTests(TestCase):
+ def test(self):
+ FloatModel.objects.create()
+ obj = FloatModel.objects.annotate(random=Random()).first()
+ self.assertIsInstance(obj.random, float)
+ self.assertGreaterEqual(obj.random, 0)
+ self.assertLess(obj.random, 1)