Refs #32632 -- Added tests for returning a copy when combining Q() objects.

This commit is contained in:
Mariusz Felisiak 2021-04-28 11:27:57 +02:00
parent 6e742dabc9
commit 4f600673d7
1 changed files with 13 additions and 0 deletions

View File

@ -26,6 +26,19 @@ class QTests(SimpleTestCase):
self.assertEqual(q | Q(), q) self.assertEqual(q | Q(), q)
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): def test_combine_or_both_empty(self):
self.assertEqual(Q() | Q(), Q()) self.assertEqual(Q() | Q(), Q())