diff options
Diffstat (limited to 'tests/aggregation_regress/tests.py')
| -rw-r--r-- | tests/aggregation_regress/tests.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py index 29b32c4987..2b3948a0b4 100644 --- a/tests/aggregation_regress/tests.py +++ b/tests/aggregation_regress/tests.py @@ -11,6 +11,7 @@ from django.db.models import ( Avg, Case, Count, DecimalField, F, IntegerField, Max, Q, StdDev, Sum, Value, Variance, When, ) +from django.db.models.aggregates import Aggregate from django.test import ( TestCase, ignore_warnings, skipUnlessAnyDBFeature, skipUnlessDBFeature, ) @@ -1496,6 +1497,16 @@ class AggregationTests(TestCase): qs = Author.objects.values_list('age', flat=True).annotate(age_count=Count('age')).filter(age_count__gt=1) self.assertSequenceEqual(qs, [29]) + def test_allow_distinct(self): + class MyAggregate(Aggregate): + pass + with self.assertRaisesMessage(TypeError, 'MyAggregate does not allow distinct'): + MyAggregate('foo', distinct=True) + + class DistinctAggregate(Aggregate): + allow_distinct = True + DistinctAggregate('foo', distinct=True) + class JoinPromotionTests(TestCase): def test_ticket_21150(self): |
