summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charettes@users.noreply.github.com>2018-10-02 19:15:20 -0400
committerTim Graham <timograham@gmail.com>2018-10-02 19:15:20 -0400
commitbc7e288ca9554ac1a0a19941302dea19df1acd21 (patch)
tree6bf15e3c89383901ac8009ade26becb23b5fc500 /tests
parente4df8e6dc021fa472fa77f9b835db74810184748 (diff)
Fixed #29745 -- Based Expression equality on detailed initialization signature.
The old implementation considered objects initialized with an equivalent signature different if some arguments were provided positionally instead of as keyword arguments. Refs #11964, #26167.
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/tests.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index c631151448..d3f86fcd92 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -11,8 +11,9 @@ from django.db.models.aggregates import (
Avg, Count, Max, Min, StdDev, Sum, Variance,
)
from django.db.models.expressions import (
- Case, Col, Combinable, Exists, ExpressionList, ExpressionWrapper, F, Func,
- OrderBy, OuterRef, Random, RawSQL, Ref, Subquery, Value, When,
+ Case, Col, Combinable, Exists, Expression, ExpressionList,
+ ExpressionWrapper, F, Func, OrderBy, OuterRef, Random, RawSQL, Ref,
+ Subquery, Value, When,
)
from django.db.models.functions import (
Coalesce, Concat, Length, Lower, Substr, Upper,
@@ -822,6 +823,31 @@ class ExpressionsTests(TestCase):
)
+class SimpleExpressionTests(SimpleTestCase):
+
+ def test_equal(self):
+ self.assertEqual(Expression(), Expression())
+ self.assertEqual(
+ Expression(models.IntegerField()),
+ Expression(output_field=models.IntegerField())
+ )
+ self.assertNotEqual(
+ Expression(models.IntegerField()),
+ Expression(models.CharField())
+ )
+
+ def test_hash(self):
+ self.assertEqual(hash(Expression()), hash(Expression()))
+ self.assertEqual(
+ hash(Expression(models.IntegerField())),
+ hash(Expression(output_field=models.IntegerField()))
+ )
+ self.assertNotEqual(
+ hash(Expression(models.IntegerField())),
+ hash(Expression(models.CharField())),
+ )
+
+
class ExpressionsNumericTests(TestCase):
def setUp(self):