Refs -- Added tests for returning a copy when combining Q() objects.
@@ -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())
