From b8c8ff7bfa38fcd1bd8c23e6ca533bf8dc37d3bd Mon Sep 17 00:00:00 2001 From: NotSqrt Date: Tue, 26 Apr 2016 20:12:04 +0200 Subject: [PATCH] Test that expressions are supported --- polymorphic/tests.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/polymorphic/tests.py b/polymorphic/tests.py index 3e1aa4f..ddc3a3b 100644 --- a/polymorphic/tests.py +++ b/polymorphic/tests.py @@ -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):