1
0
mirror of https://github.com/django/django.git synced 2024-12-23 17:46:27 +00:00
django/tests/expressions/test_deprecation.py

25 lines
722 B
Python
Raw Normal View History

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'))