| 30 | self.assertAlmostEqual(obj.f_mod, math.fmod(obj.f1, obj.f2)) |
| 31 | |
| 32 | def test_integer(self): |
| 33 | IntegerModel.objects.create(small=20, normal=15, big=1) |
| 34 | obj = IntegerModel.objects.annotate( |
| 35 | small_mod=Mod("small", "normal"), |
| 36 | normal_mod=Mod("normal", "big"), |
| 37 | big_mod=Mod("big", "small"), |
| 38 | ).first() |
| 39 | self.assertIsInstance(obj.small_mod, float) |
| 40 | self.assertIsInstance(obj.normal_mod, float) |
| 41 | self.assertIsInstance(obj.big_mod, float) |
| 42 | self.assertEqual(obj.small_mod, math.fmod(obj.small, obj.normal)) |
| 43 | self.assertEqual(obj.normal_mod, math.fmod(obj.normal, obj.big)) |
| 44 | self.assertEqual(obj.big_mod, math.fmod(obj.big, obj.small)) |