mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			14 lines
		
	
	
		
			401 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			14 lines
		
	
	
		
			401 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| 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)
 |