summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2019-03-19 01:05:47 -0400
committerTim Graham <timograham@gmail.com>2019-03-21 18:47:46 -0400
commit9dc367dc10594ad024c83d398a8e3c3f8f221446 (patch)
tree4b0d07779536cac024a2edc44271f7d665dd3637 /tests
parent2aaabe2004e1953eb7d7057edcf2fabd37f7394d (diff)
Refs #30158 -- Added alias argument to Expression.get_group_by_cols().
Diffstat (limited to 'tests')
-rw-r--r--tests/expressions/test_deprecation.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/expressions/test_deprecation.py b/tests/expressions/test_deprecation.py
new file mode 100644
index 0000000000..cdb1e43af6
--- /dev/null
+++ b/tests/expressions/test_deprecation.py
@@ -0,0 +1,24 @@
+from django.db.models import Count, Func
+from django.test import SimpleTestCase
+from django.utils.deprecation import RemovedInDjango40Warning
+
+from .models import Employee
+
+
+class MissingAliasFunc(Func):
+ template = '1'
+
+ def get_group_by_cols(self):
+ return []
+
+
+class GetGroupByColsTest(SimpleTestCase):
+ def test_missing_alias(self):
+ msg = (
+ '`alias=None` must be added to the signature of '
+ 'expressions.test_deprecation.MissingAliasFunc.get_group_by_cols().'
+ )
+ with self.assertRaisesMessage(RemovedInDjango40Warning, msg):
+ Employee.objects.values(
+ one=MissingAliasFunc(),
+ ).annotate(cnt=Count('company_ceo_set'))