mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Refs #33476 -- Reformatted code with Black.
This commit is contained in:
committed by
Mariusz Felisiak
parent
f68fa8b45d
commit
9c19aff7c7
@@ -10,15 +10,14 @@ from ..models import DecimalModel, FloatModel, IntegerModel
|
||||
|
||||
|
||||
class LnTests(TestCase):
|
||||
|
||||
def test_null(self):
|
||||
IntegerModel.objects.create()
|
||||
obj = IntegerModel.objects.annotate(null_ln=Ln('normal')).first()
|
||||
obj = IntegerModel.objects.annotate(null_ln=Ln("normal")).first()
|
||||
self.assertIsNone(obj.null_ln)
|
||||
|
||||
def test_decimal(self):
|
||||
DecimalModel.objects.create(n1=Decimal('12.9'), n2=Decimal('0.6'))
|
||||
obj = DecimalModel.objects.annotate(n1_ln=Ln('n1'), n2_ln=Ln('n2')).first()
|
||||
DecimalModel.objects.create(n1=Decimal("12.9"), n2=Decimal("0.6"))
|
||||
obj = DecimalModel.objects.annotate(n1_ln=Ln("n1"), n2_ln=Ln("n2")).first()
|
||||
self.assertIsInstance(obj.n1_ln, Decimal)
|
||||
self.assertIsInstance(obj.n2_ln, Decimal)
|
||||
self.assertAlmostEqual(obj.n1_ln, Decimal(math.log(obj.n1)))
|
||||
@@ -26,7 +25,7 @@ class LnTests(TestCase):
|
||||
|
||||
def test_float(self):
|
||||
FloatModel.objects.create(f1=27.5, f2=0.33)
|
||||
obj = FloatModel.objects.annotate(f1_ln=Ln('f1'), f2_ln=Ln('f2')).first()
|
||||
obj = FloatModel.objects.annotate(f1_ln=Ln("f1"), f2_ln=Ln("f2")).first()
|
||||
self.assertIsInstance(obj.f1_ln, float)
|
||||
self.assertIsInstance(obj.f2_ln, float)
|
||||
self.assertAlmostEqual(obj.f1_ln, math.log(obj.f1))
|
||||
@@ -35,9 +34,9 @@ class LnTests(TestCase):
|
||||
def test_integer(self):
|
||||
IntegerModel.objects.create(small=20, normal=15, big=1)
|
||||
obj = IntegerModel.objects.annotate(
|
||||
small_ln=Ln('small'),
|
||||
normal_ln=Ln('normal'),
|
||||
big_ln=Ln('big'),
|
||||
small_ln=Ln("small"),
|
||||
normal_ln=Ln("normal"),
|
||||
big_ln=Ln("big"),
|
||||
).first()
|
||||
self.assertIsInstance(obj.small_ln, float)
|
||||
self.assertIsInstance(obj.normal_ln, float)
|
||||
@@ -48,7 +47,7 @@ class LnTests(TestCase):
|
||||
|
||||
def test_transform(self):
|
||||
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'))
|
||||
DecimalModel.objects.create(n1=Decimal("12.0"), n2=Decimal("0"))
|
||||
DecimalModel.objects.create(n1=Decimal("1.0"), n2=Decimal("0"))
|
||||
obj = DecimalModel.objects.filter(n1__ln__gt=0).get()
|
||||
self.assertEqual(obj.n1, Decimal('12.0'))
|
||||
self.assertEqual(obj.n1, Decimal("12.0"))
|
||||
|
||||
Reference in New Issue
Block a user