summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2022-07-23 13:31:35 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-07-27 07:55:09 +0200
commit769d7cce4aedfcbba59f1b68577225d07701c206 (patch)
treec896675140b6d356bf35db97df06b9d83dad67f5 /tests/queries
parente20e5d1557785ba71e8ef0ceb8ccb85bdc13840a (diff)
downloaddjango-769d7cce4aedfcbba59f1b68577225d07701c206.tar.gz
Used AND, OR, XOR constants instead of hard-coded values.
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/test_q.py4
-rw-r--r--tests/queries/test_query.py4
-rw-r--r--tests/queries/tests.py14
3 files changed, 11 insertions, 11 deletions
diff --git a/tests/queries/test_q.py b/tests/queries/test_q.py
index 4801eb4807..289305d33f 100644
--- a/tests/queries/test_q.py
+++ b/tests/queries/test_q.py
@@ -114,7 +114,7 @@ class QTests(SimpleTestCase):
("price", F("discounted_price")),
),
)
- self.assertEqual(kwargs, {"_connector": "OR"})
+ self.assertEqual(kwargs, {"_connector": Q.OR})
def test_deconstruct_xor(self):
q1 = Q(price__gt=F("discounted_price"))
@@ -128,7 +128,7 @@ class QTests(SimpleTestCase):
("price", F("discounted_price")),
),
)
- self.assertEqual(kwargs, {"_connector": "XOR"})
+ self.assertEqual(kwargs, {"_connector": Q.XOR})
def test_deconstruct_and(self):
q1 = Q(price__gt=F("discounted_price"))
diff --git a/tests/queries/test_query.py b/tests/queries/test_query.py
index 9884116cd0..b0a5058f6c 100644
--- a/tests/queries/test_query.py
+++ b/tests/queries/test_query.py
@@ -16,7 +16,7 @@ from django.db.models.functions import Lower
from django.db.models.lookups import Exact, GreaterThan, IsNull, LessThan
from django.db.models.sql.constants import SINGLE
from django.db.models.sql.query import JoinPromoter, Query, get_field_names_from_opts
-from django.db.models.sql.where import OR
+from django.db.models.sql.where import AND, OR
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import register_lookup
@@ -214,6 +214,6 @@ class TestQueryNoModel(TestCase):
class JoinPromoterTest(SimpleTestCase):
def test_repr(self):
self.assertEqual(
- repr(JoinPromoter("AND", 3, True)),
+ repr(JoinPromoter(AND, 3, True)),
"JoinPromoter(connector='AND', num_children=3, negated=True)",
)
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 00213f0dfc..1238f021be 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -10,7 +10,7 @@ from django.db import DEFAULT_DB_ALIAS, connection
from django.db.models import Count, Exists, F, Max, OuterRef, Q
from django.db.models.expressions import RawSQL
from django.db.models.sql.constants import LOUTER
-from django.db.models.sql.where import NothingNode, WhereNode
+from django.db.models.sql.where import AND, OR, NothingNode, WhereNode
from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature
from django.test.utils import CaptureQueriesContext, ignore_warnings
from django.utils.deprecation import RemovedInDjango50Warning
@@ -3559,16 +3559,16 @@ class WhereNodeTest(SimpleTestCase):
def test_empty_full_handling_disjunction(self):
compiler = WhereNodeTest.MockCompiler()
- w = WhereNode(children=[NothingNode()], connector="OR")
+ w = WhereNode(children=[NothingNode()], connector=OR)
with self.assertRaises(EmptyResultSet):
w.as_sql(compiler, connection)
w.negate()
self.assertEqual(w.as_sql(compiler, connection), ("", []))
- w = WhereNode(children=[self.DummyNode(), self.DummyNode()], connector="OR")
+ w = WhereNode(children=[self.DummyNode(), self.DummyNode()], connector=OR)
self.assertEqual(w.as_sql(compiler, connection), ("(dummy OR dummy)", []))
w.negate()
self.assertEqual(w.as_sql(compiler, connection), ("NOT (dummy OR dummy)", []))
- w = WhereNode(children=[NothingNode(), self.DummyNode()], connector="OR")
+ w = WhereNode(children=[NothingNode(), self.DummyNode()], connector=OR)
self.assertEqual(w.as_sql(compiler, connection), ("dummy", []))
w.negate()
self.assertEqual(w.as_sql(compiler, connection), ("NOT (dummy)", []))
@@ -3581,14 +3581,14 @@ class WhereNodeTest(SimpleTestCase):
w.negate()
with self.assertRaises(EmptyResultSet):
w.as_sql(compiler, connection)
- w.connector = "OR"
+ w.connector = OR
with self.assertRaises(EmptyResultSet):
w.as_sql(compiler, connection)
w.negate()
self.assertEqual(w.as_sql(compiler, connection), ("", []))
- w = WhereNode(children=[empty_w, NothingNode()], connector="OR")
+ w = WhereNode(children=[empty_w, NothingNode()], connector=OR)
self.assertEqual(w.as_sql(compiler, connection), ("", []))
- w = WhereNode(children=[empty_w, NothingNode()], connector="AND")
+ w = WhereNode(children=[empty_w, NothingNode()], connector=AND)
with self.assertRaises(EmptyResultSet):
w.as_sql(compiler, connection)