MCPcopy
hub / github.com/django/django / test_flatten

Method test_flatten

tests/queries/test_q.py:250–264  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

248 )
249
250 def test_flatten(self):
251 q = Q()
252 self.assertEqual(list(q.flatten()), [q])
253 q = Q(NothingNode())
254 self.assertEqual(list(q.flatten()), [q, q.children[0]])
255 q = Q(
256 ExpressionWrapper(
257 Q(RawSQL("id = 0", params=(), output_field=BooleanField()))
258 | Q(price=Value("4.55"))
259 | Q(name=Lower("category")),
260 output_field=BooleanField(),
261 )
262 )
263 flatten = list(q.flatten())
264 self.assertEqual(len(flatten), 7)
265
266 def test_create_helper(self):
267 items = [("a", 1), ("b", 2), ("c", 3)]

Callers

nothing calls this directly

Calls 8

flattenMethod · 0.95
QClass · 0.90
NothingNodeClass · 0.90
ExpressionWrapperClass · 0.90
RawSQLClass · 0.90
BooleanFieldClass · 0.90
ValueClass · 0.90
LowerClass · 0.90

Tested by

no test coverage detected