Test that expressions are supported

fix_request_path_info
NotSqrt 2016-04-26 20:12:04 +02:00
parent 5aa15b226e
commit b8c8ff7bfa
1 changed files with 14 additions and 0 deletions

View File

@ -420,6 +420,11 @@ class CustomPkInherit(CustomPkBase):
i = models.CharField(max_length=1)
class DateModel(PolymorphicModel):
date = models.DateTimeField()
class PolymorphicTests(TestCase):
"""
The test suite
@ -1137,6 +1142,15 @@ class PolymorphicTests(TestCase):
with self.assertRaisesMessage(AssertionError, 'PolymorphicModel: annotate()/aggregate(): ___ model lookup supported for keyword arguments only'):
Model2A.objects.aggregate(ComplexAgg('Model2B___field2'))
@skipIf(django.VERSION < (1,8,), "This test needs Django >=1.8")
def test_polymorphic__expressions(self):
from django.db.models.expressions import DateTime
from django.utils.timezone import utc
# no exception raised
result = DateModel.objects.annotate(val=DateTime('date', 'day', utc))
self.assertEqual(list(result), [])
class RegressionTests(TestCase):