MCPcopy
hub / github.com/django/django / test_combine_isnull

Method test_combine_isnull

tests/null_fk/tests.py:47–67  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

45 )
46
47 def test_combine_isnull(self):
48 item = Item.objects.create(title="Some Item")
49 pv = PropertyValue.objects.create(label="Some Value")
50 item.props.create(key="a", value=pv)
51 item.props.create(key="b") # value=NULL
52 q1 = Q(props__key="a", props__value=pv)
53 q2 = Q(props__key="b", props__value__isnull=True)
54
55 # Each of these individually should return the item.
56 self.assertEqual(Item.objects.get(q1), item)
57 self.assertEqual(Item.objects.get(q2), item)
58
59 # Logically, qs1 and qs2, and qs3 and qs4 should be the same.
60 qs1 = Item.objects.filter(q1) & Item.objects.filter(q2)
61 qs2 = Item.objects.filter(q2) & Item.objects.filter(q1)
62 qs3 = Item.objects.filter(q1) | Item.objects.filter(q2)
63 qs4 = Item.objects.filter(q2) | Item.objects.filter(q1)
64
65 # Regression test for #15823.
66 self.assertEqual(list(qs1), list(qs2))
67 self.assertEqual(list(qs3), list(qs4))

Callers

nothing calls this directly

Calls 4

QClass · 0.90
createMethod · 0.45
getMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected