From 4f600673d71cd99918755805042b7c039645f712 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Wed, 28 Apr 2021 11:27:57 +0200 Subject: [PATCH] Refs #32632 -- Added tests for returning a copy when combining Q() objects. --- tests/queries/test_q.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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())