From a6074e8908e36286de7e31f165be801df8ee1eab Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Tue, 5 Apr 2016 23:48:08 -0400 Subject: Fixed #26458 -- Based Avg's default output_field resolution on its source field type. Thanks Tim for the review and Josh for the input. --- tests/aggregation/tests.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/aggregation') diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py index 2e68d0a7f3..758b101157 100644 --- a/tests/aggregation/tests.py +++ b/tests/aggregation/tests.py @@ -496,10 +496,16 @@ class AggregateTestCase(TestCase): self.assertEqual(vals, {"num_authors__avg": Approximate(1.66, places=1)}) def test_avg_duration_field(self): + # Explicit `output_field`. self.assertEqual( Publisher.objects.aggregate(Avg('duration', output_field=DurationField())), {'duration__avg': datetime.timedelta(days=1, hours=12)} ) + # Implicit `output_field`. + self.assertEqual( + Publisher.objects.aggregate(Avg('duration')), + {'duration__avg': datetime.timedelta(days=1, hours=12)} + ) def test_sum_duration_field(self): self.assertEqual( -- cgit v1.3