MCPcopy
hub / github.com/django/django / test_cast_to_integer

Method test_cast_to_integer

tests/db_functions/comparison/test_cast.py:64–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

62 self.assertEqual(author_obj.cast_alias_decimal, decimal.Decimal("1"))
63
64 def test_cast_to_integer(self):
65 for field_class in (
66 models.AutoField,
67 models.BigAutoField,
68 models.SmallAutoField,
69 models.IntegerField,
70 models.BigIntegerField,
71 models.SmallIntegerField,
72 models.PositiveBigIntegerField,
73 models.PositiveIntegerField,
74 models.PositiveSmallIntegerField,
75 ):
76 with self.subTest(field_class=field_class):
77 numbers = Author.objects.annotate(cast_int=Cast("alias", field_class()))
78 self.assertEqual(numbers.get().cast_int, 1)
79
80 def test_cast_to_integer_foreign_key(self):
81 numbers = Author.objects.annotate(

Callers

nothing calls this directly

Calls 3

CastClass · 0.90
annotateMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected