summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergey Fedoseev <fedoseev.sergey@gmail.com>2017-07-07 09:04:37 +0500
committerTim Graham <timograham@gmail.com>2017-07-11 08:29:08 -0400
commit29769a9942b08c86397692fa164396a670a4e1ec (patch)
tree1f57a20a43940fd60a997111e2d1e5beffc3d422 /tests
parent306b961a4dc1fd308c6f298b406fb41906ebaf2d (diff)
Fixed #28382 -- Prevented BaseExpression._output_field from being set if _resolve_output_field() fails.
Diffstat (limited to 'tests')
-rw-r--r--tests/aggregation/tests.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index c3f7998f60..3c53877303 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -965,8 +965,12 @@ class AggregateTestCase(TestCase):
self.assertEqual(p2, {'avg_price': Approximate(53.39, places=2)})
def test_combine_different_types(self):
- with self.assertRaisesMessage(FieldError, 'Expression contains mixed types. You must set output_field'):
- Book.objects.annotate(sums=Sum('rating') + Sum('pages') + Sum('price')).get(pk=self.b4.pk)
+ msg = 'Expression contains mixed types. You must set output_field.'
+ qs = Book.objects.annotate(sums=Sum('rating') + Sum('pages') + Sum('price'))
+ with self.assertRaisesMessage(FieldError, msg):
+ qs.first()
+ with self.assertRaisesMessage(FieldError, msg):
+ qs.first()
b1 = Book.objects.annotate(sums=Sum(F('rating') + F('pages') + F('price'),
output_field=IntegerField())).get(pk=self.b4.pk)