summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-28 11:27:57 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-04-28 11:31:17 +0200
commit4f600673d71cd99918755805042b7c039645f712 (patch)
tree6dd12b03b336b1f8c4aa45203b8fd4208174c506 /tests/queries
parent6e742dabc95b00ba896434293556adeb4dbaee8a (diff)
downloaddjango-4f600673d71cd99918755805042b7c039645f712.tar.gz
Refs #32632 -- Added tests for returning a copy when combining Q() objects.
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/test_q.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/queries/test_q.py b/tests/queries/test_q.py
index 24a705f07f..84ae6e90a5 100644
--- a/tests/queries/test_q.py
+++ b/tests/queries/test_q.py
@@ -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())