mirror of https://github.com/django/django.git
Refs #32632 -- Added tests for returning a copy when combining Q() objects.
This commit is contained in:
parent
6e742dabc9
commit
4f600673d7
|
@ -26,6 +26,19 @@ class QTests(SimpleTestCase):
|
|||
self.assertEqual(q | Q(), q)
|
||||
self.assertEqual(Q() | q, q)
|
||||
|
||||
def test_combine_empty_copy(self):
|
||||
base_q = Q(x=1)
|
||||
tests = [
|
||||
base_q | Q(),
|
||||
Q() | base_q,
|
||||
base_q & Q(),
|
||||
Q() & base_q,
|
||||
]
|
||||
for i, q in enumerate(tests):
|
||||
with self.subTest(i=i):
|
||||
self.assertEqual(q, base_q)
|
||||
self.assertIsNot(q, base_q)
|
||||
|
||||
def test_combine_or_both_empty(self):
|
||||
self.assertEqual(Q() | Q(), Q())
|
||||
|
||||
|
|
Loading…
Reference in New Issue