summaryrefslogtreecommitdiff
path: root/tests/aggregation
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2014-11-16 02:05:54 +0100
committerSimon Charette <charette.s@gmail.com>2014-11-16 02:12:36 +0100
commit68ef44c565d901945eb74768d439c93678315cf6 (patch)
tree344b6ff1ae9b57b6cae465f460fabe0d4958901e /tests/aggregation
parent5b9470efd8725eb349e6f3a66b0ea1073ede5b47 (diff)
Removed references to the deprecated assertRaisesRegexp method.
Diffstat (limited to 'tests/aggregation')
-rw-r--r--tests/aggregation/tests.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 851ce69db0..8c6529c73b 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -17,6 +17,7 @@ with warnings.catch_warnings(record=True) as w:
from django.test import TestCase
from django.test.utils import Approximate
from django.test.utils import CaptureQueriesContext
+from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from .models import Author, Publisher, Book, Store
@@ -693,7 +694,7 @@ class ComplexAggregateTestCase(TestCase):
fixtures = ["aggregation.json"]
def test_nonaggregate_aggregation_throws(self):
- with self.assertRaisesRegexp(TypeError, 'fail is not an aggregate expression'):
+ with six.assertRaisesRegex(self, TypeError, 'fail is not an aggregate expression'):
Book.objects.aggregate(fail=F('price'))
def test_nonfield_annotation(self):
@@ -703,7 +704,7 @@ class ComplexAggregateTestCase(TestCase):
self.assertEqual(book.val, 2)
def test_missing_output_field_raises_error(self):
- with self.assertRaisesRegexp(FieldError, 'Cannot resolve expression type, unknown output_field'):
+ with six.assertRaisesRegex(self, FieldError, 'Cannot resolve expression type, unknown output_field'):
Book.objects.annotate(val=Max(Value(2)))[0]
def test_annotation_expressions(self):
@@ -742,7 +743,7 @@ class ComplexAggregateTestCase(TestCase):
self.assertEqual(p2, {'avg_price': Approximate(53.39, places=2)})
def test_combine_different_types(self):
- with self.assertRaisesRegexp(FieldError, 'Expression contains mixed types. You must set output_field'):
+ with six.assertRaisesRegex(self, FieldError, 'Expression contains mixed types. You must set output_field'):
Book.objects.annotate(sums=Sum('rating') + Sum('pages') + Sum('price')).get(pk=4)
b1 = Book.objects.annotate(sums=Sum(F('rating') + F('pages') + F('price'),
@@ -758,9 +759,9 @@ class ComplexAggregateTestCase(TestCase):
self.assertEqual(b3.sums, Decimal("383.69"))
def test_complex_aggregations_require_kwarg(self):
- with self.assertRaisesRegexp(TypeError, 'Complex expressions require an alias'):
+ with six.assertRaisesRegex(self, TypeError, 'Complex expressions require an alias'):
Author.objects.annotate(Sum(F('age') + F('friends__age')))
- with self.assertRaisesRegexp(TypeError, 'Complex aggregates require an alias'):
+ with six.assertRaisesRegex(self, TypeError, 'Complex aggregates require an alias'):
Author.objects.aggregate(Sum('age') / Count('age'))
def test_aggregate_over_complex_annotation(self):
@@ -856,7 +857,7 @@ class ComplexAggregateTestCase(TestCase):
self.assertEqual(author.sum_age, other_author.sum_age)
def test_annotated_aggregate_over_annotated_aggregate(self):
- with self.assertRaisesRegexp(FieldError, "Cannot compute Sum\('id__max'\): 'id__max' is an aggregate"):
+ with six.assertRaisesRegex(self, FieldError, "Cannot compute Sum\('id__max'\): 'id__max' is an aggregate"):
Book.objects.annotate(Max('id')).annotate(Sum('id__max'))
def test_add_implementation(self):