[2.2.x] Simplified test_transform()s in db_functions.math.

Backport of 258110d6cd from master.
This commit is contained in:
Mariusz Felisiak 2019-03-15 00:42:01 +01:00 committed by Tim Graham
parent a9ce7e2bcd
commit b150d99460
16 changed files with 32 additions and 32 deletions

View File

@ -49,5 +49,5 @@ class AbsTests(TestCase):
with register_lookup(DecimalField, Abs):
DecimalModel.objects.create(n1=Decimal('-1.5'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-0.5'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__abs__gt=1)
self.assertQuerysetEqual(objs, [Decimal('-1.5')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__abs__gt=1).get()
self.assertEqual(obj.n1, Decimal('-1.5'))

View File

@ -50,5 +50,5 @@ class ACosTests(TestCase):
with register_lookup(DecimalField, ACos):
DecimalModel.objects.create(n1=Decimal('0.5'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-0.9'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__acos__lt=2)
self.assertQuerysetEqual(objs, [Decimal('0.5')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__acos__lt=2).get()
self.assertEqual(obj.n1, Decimal('0.5'))

View File

@ -50,5 +50,5 @@ class ASinTests(TestCase):
with register_lookup(DecimalField, ASin):
DecimalModel.objects.create(n1=Decimal('0.1'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__asin__gt=1)
self.assertQuerysetEqual(objs, [Decimal('1.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__asin__gt=1).get()
self.assertEqual(obj.n1, Decimal('1.0'))

View File

@ -50,5 +50,5 @@ class ATanTests(TestCase):
with register_lookup(DecimalField, ATan):
DecimalModel.objects.create(n1=Decimal('3.12'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-5'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__atan__gt=0)
self.assertQuerysetEqual(objs, [Decimal('3.12')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__atan__gt=0).get()
self.assertEqual(obj.n1, Decimal('3.12'))

View File

@ -50,5 +50,5 @@ class CeilTests(TestCase):
with register_lookup(DecimalField, Ceil):
DecimalModel.objects.create(n1=Decimal('3.12'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('1.25'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__ceil__gt=3)
self.assertQuerysetEqual(objs, [Decimal('3.12')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__ceil__gt=3).get()
self.assertEqual(obj.n1, Decimal('3.12'))

View File

@ -50,5 +50,5 @@ class CosTests(TestCase):
with register_lookup(DecimalField, Cos):
DecimalModel.objects.create(n1=Decimal('-8.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('3.14'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__cos__gt=-0.2)
self.assertQuerysetEqual(objs, [Decimal('-8.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__cos__gt=-0.2).get()
self.assertEqual(obj.n1, Decimal('-8.0'))

View File

@ -50,5 +50,5 @@ class CotTests(TestCase):
with register_lookup(DecimalField, Cot):
DecimalModel.objects.create(n1=Decimal('12.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__cot__gt=0)
self.assertQuerysetEqual(objs, [Decimal('1.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__cot__gt=0).get()
self.assertEqual(obj.n1, Decimal('1.0'))

View File

@ -50,5 +50,5 @@ class DegreesTests(TestCase):
with register_lookup(DecimalField, Degrees):
DecimalModel.objects.create(n1=Decimal('5.4'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-30'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__degrees__gt=0)
self.assertQuerysetEqual(objs, [Decimal('5.4')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__degrees__gt=0).get()
self.assertEqual(obj.n1, Decimal('5.4'))

View File

@ -50,5 +50,5 @@ class ExpTests(TestCase):
with register_lookup(DecimalField, Exp):
DecimalModel.objects.create(n1=Decimal('12.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__exp__gt=10)
self.assertQuerysetEqual(objs, [Decimal('12.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__exp__gt=10).get()
self.assertEqual(obj.n1, Decimal('12.0'))

View File

@ -50,5 +50,5 @@ class FloorTests(TestCase):
with register_lookup(DecimalField, Floor):
DecimalModel.objects.create(n1=Decimal('5.4'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('3.4'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__floor__gt=4)
self.assertQuerysetEqual(objs, [Decimal('5.4')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__floor__gt=4).get()
self.assertEqual(obj.n1, Decimal('5.4'))

View File

@ -50,5 +50,5 @@ class LnTests(TestCase):
with register_lookup(DecimalField, Ln):
DecimalModel.objects.create(n1=Decimal('12.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__ln__gt=0)
self.assertQuerysetEqual(objs, [Decimal('12.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__ln__gt=0).get()
self.assertEqual(obj.n1, Decimal('12.0'))

View File

@ -50,5 +50,5 @@ class RadiansTests(TestCase):
with register_lookup(DecimalField, Radians):
DecimalModel.objects.create(n1=Decimal('2.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__radians__gt=0)
self.assertQuerysetEqual(objs, [Decimal('2.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__radians__gt=0).get()
self.assertEqual(obj.n1, Decimal('2.0'))

View File

@ -49,5 +49,5 @@ class RoundTests(TestCase):
with register_lookup(DecimalField, Round):
DecimalModel.objects.create(n1=Decimal('2.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('-1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__round__gt=0)
self.assertQuerysetEqual(objs, [Decimal('2.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__round__gt=0).get()
self.assertEqual(obj.n1, Decimal('2.0'))

View File

@ -50,5 +50,5 @@ class SinTests(TestCase):
with register_lookup(DecimalField, Sin):
DecimalModel.objects.create(n1=Decimal('5.4'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('0.1'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__sin__lt=0)
self.assertQuerysetEqual(objs, [Decimal('5.4')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__sin__lt=0).get()
self.assertEqual(obj.n1, Decimal('5.4'))

View File

@ -50,5 +50,5 @@ class SqrtTests(TestCase):
with register_lookup(DecimalField, Sqrt):
DecimalModel.objects.create(n1=Decimal('6.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('1.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__sqrt__gt=2)
self.assertQuerysetEqual(objs, [Decimal('6.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__sqrt__gt=2).get()
self.assertEqual(obj.n1, Decimal('6.0'))

View File

@ -50,5 +50,5 @@ class TanTests(TestCase):
with register_lookup(DecimalField, Tan):
DecimalModel.objects.create(n1=Decimal('0.0'), n2=Decimal('0'))
DecimalModel.objects.create(n1=Decimal('12.0'), n2=Decimal('0'))
objs = DecimalModel.objects.filter(n1__tan__lt=0)
self.assertQuerysetEqual(objs, [Decimal('12.0')], lambda a: a.n1)
obj = DecimalModel.objects.filter(n1__tan__lt=0).get()
self.assertEqual(obj.n1, Decimal('12.0'))