diff options
| author | François Freitag <francois.freitag@gmail.com> | 2016-09-17 06:29:14 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-09-17 09:29:14 -0400 |
| commit | 631ef6b2729f79c75f35cd32caa504dda7c32e9e (patch) | |
| tree | a965597f3c1260ef2e956fafcf46a9b0e8727f91 /tests | |
| parent | 9027e6c8a3711034d345535036d1a276d9a8b829 (diff) | |
Made FieldError/FieldDoesNotExist messages uniform across Python versions.
Removed possible u'' prefixes on Python 2.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/annotations/tests.py | 4 | ||||
| -rw-r--r-- | tests/dates/tests.py | 6 | ||||
| -rw-r--r-- | tests/expressions/tests.py | 2 |
3 files changed, 5 insertions, 7 deletions
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py index 28627e84ae..ad2f071fa4 100644 --- a/tests/annotations/tests.py +++ b/tests/annotations/tests.py @@ -237,7 +237,7 @@ class NonAggregateAnnotationTestCase(TestCase): self.assertEqual(book.sum_rating, book.rating) def test_filter_wrong_annotation(self): - with six.assertRaisesRegex(self, FieldError, "Cannot resolve keyword .*"): + with self.assertRaisesMessage(FieldError, "Cannot resolve keyword 'nope' into field."): list(Book.objects.annotate( sum_rating=Sum('rating') ).filter(sum_rating=F('nope'))) @@ -307,7 +307,7 @@ class NonAggregateAnnotationTestCase(TestCase): self.assertEqual(book.rating, 5) self.assertEqual(book.other_rating, 4) - with six.assertRaisesRegex(self, FieldDoesNotExist, "\w has no field named u?'other_rating'"): + with self.assertRaisesMessage(FieldDoesNotExist, "Book has no field named 'other_rating'"): book = qs.defer('other_rating').get(other_rating=4) def test_mti_annotations(self): diff --git a/tests/dates/tests.py b/tests/dates/tests.py index b7c7312c17..503d921ee1 100644 --- a/tests/dates/tests.py +++ b/tests/dates/tests.py @@ -6,7 +6,6 @@ from unittest import skipUnless from django.core.exceptions import FieldError from django.db import connection from django.test import TestCase, override_settings -from django.utils import six from .models import Article, Category, Comment @@ -86,10 +85,9 @@ class DatesTests(TestCase): Article.objects.dates() def test_dates_fails_when_given_invalid_field_argument(self): - six.assertRaisesRegex( - self, + self.assertRaisesMessage( FieldError, - "Cannot resolve keyword u?'invalid_field' into field. Choices are: " + "Cannot resolve keyword 'invalid_field' into field. Choices are: " "categories, comments, id, pub_date, pub_datetime, title", Article.objects.dates, "invalid_field", diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py index 196543f4a3..033a5e8912 100644 --- a/tests/expressions/tests.py +++ b/tests/expressions/tests.py @@ -688,7 +688,7 @@ class ExpressionsNumericTests(TestCase): self.assertEqual(Number.objects.get(pk=n.pk).float, Approximate(256.900, places=3)) def test_incorrect_field_expression(self): - with six.assertRaisesRegex(self, FieldError, "Cannot resolve keyword u?'nope' into field.*"): + with self.assertRaisesMessage(FieldError, "Cannot resolve keyword 'nope' into field."): list(Employee.objects.filter(firstname=F('nope'))) |
