diff options
| author | Mads Jensen <mje@inducks.org> | 2017-05-28 21:37:21 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-07-29 19:07:23 -0400 |
| commit | a51c4de1945be2225f20fad794cfb52d8f1f9236 (patch) | |
| tree | 36386b70a27cf027a8a491de319c3e59e0d3d0cd /tests/distinct_on_fields | |
| parent | 38988f289f7f5708f5ea85de2d5dfe0d86b23106 (diff) | |
Used assertRaisesMessage() to test Django's error messages.
Diffstat (limited to 'tests/distinct_on_fields')
| -rw-r--r-- | tests/distinct_on_fields/tests.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py index 6bb518d2b1..93a332cf83 100644 --- a/tests/distinct_on_fields/tests.py +++ b/tests/distinct_on_fields/tests.py @@ -97,16 +97,18 @@ class DistinctOnTests(TestCase): def test_distinct_not_implemented_checks(self): # distinct + annotate not allowed - with self.assertRaises(NotImplementedError): + msg = 'annotate() + distinct(fields) is not implemented.' + with self.assertRaisesMessage(NotImplementedError, msg): Celebrity.objects.annotate(Max('id')).distinct('id')[0] - with self.assertRaises(NotImplementedError): + with self.assertRaisesMessage(NotImplementedError, msg): Celebrity.objects.distinct('id').annotate(Max('id'))[0] # However this check is done only when the query executes, so you # can use distinct() to remove the fields before execution. Celebrity.objects.distinct('id').annotate(Max('id')).distinct()[0] # distinct + aggregate not allowed - with self.assertRaises(NotImplementedError): + msg = 'aggregate() + distinct(fields) not implemented.' + with self.assertRaisesMessage(NotImplementedError, msg): Celebrity.objects.distinct('id').aggregate(Max('id')) def test_distinct_on_in_ordered_subquery(self): |
