MCPcopy
hub / github.com/django/django / test_expressions

Method test_expressions

tests/db_functions/text/test_substr.py:41–48  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

39 Author.objects.annotate(raises=Substr("name", 0))
40
41 def test_expressions(self):
42 Author.objects.create(name="John Smith", alias="smithj")
43 Author.objects.create(name="Rhonda")
44 substr = Substr(Upper("name"), StrIndex("name", V("h")), 5)
45 authors = Author.objects.annotate(name_part=substr)
46 self.assertQuerySetEqual(
47 authors.order_by("name"), ["HN SM", "HONDA"], lambda a: a.name_part
48 )

Callers

nothing calls this directly

Calls 7

SubstrClass · 0.90
UpperClass · 0.90
StrIndexClass · 0.90
annotateMethod · 0.80
assertQuerySetEqualMethod · 0.80
order_byMethod · 0.80
createMethod · 0.45

Tested by

no test coverage detected