summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2021-09-21 00:49:16 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-27 10:06:24 +0200
commit9dff316be41847c505ebf397e4a52a0a71e0acc4 (patch)
tree1bf4412223b6c0467ae5107df9422ea1406b86d6 /tests/queries
parent845667f2d1eb7063c568764a01fc9ee633ec5817 (diff)
downloaddjango-9dff316be41847c505ebf397e4a52a0a71e0acc4.tar.gz
Refs #32948, Refs #32946 -- Used Q.create() internally for dynamic Q() objects.
Node.create() which has a compatible signature with Node.__init__() takes in a single `children` argument rather than relying in unpacking *args in Q.__init__() which calls Node.__init__(). In addition, we were often needing to unpack iterables into *args and can instead pass a list direct to Node.create().
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/test_q.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/queries/test_q.py b/tests/queries/test_q.py
index 289305d33f..923846b5a3 100644
--- a/tests/queries/test_q.py
+++ b/tests/queries/test_q.py
@@ -216,6 +216,15 @@ class QTests(SimpleTestCase):
flatten = list(q.flatten())
self.assertEqual(len(flatten), 7)
+ def test_create_helper(self):
+ items = [("a", 1), ("b", 2), ("c", 3)]
+ for connector in [Q.AND, Q.OR, Q.XOR]:
+ with self.subTest(connector=connector):
+ self.assertEqual(
+ Q.create(items, connector=connector),
+ Q(*items, _connector=connector),
+ )
+
class QCheckTests(TestCase):
def test_basic(self):