summaryrefslogtreecommitdiff
path: root/tests/queries
diff options
context:
space:
mode:
Diffstat (limited to 'tests/queries')
-rw-r--r--tests/queries/tests.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index ac4e8849c4..fa87e7859c 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -417,9 +417,10 @@ class Queries1Tests(TestCase):
def test_heterogeneous_qs_combination(self):
# Combining querysets built on different models should behave in a well-defined
# fashion. We raise an error.
- with self.assertRaisesMessage(AssertionError, 'Cannot combine queries on two different base models.'):
+ msg = 'Cannot combine queries on two different base models.'
+ with self.assertRaisesMessage(TypeError, msg):
Author.objects.all() & Tag.objects.all()
- with self.assertRaisesMessage(AssertionError, 'Cannot combine queries on two different base models.'):
+ with self.assertRaisesMessage(TypeError, msg):
Author.objects.all() | Tag.objects.all()
def test_ticket3141(self):
@@ -1226,10 +1227,11 @@ class Queries3Tests(TestCase):
# This shouldn't create an infinite loop.
self.assertQuerysetEqual(Valid.objects.all(), [])
- def test_ticket8683(self):
+ def test_datetimes_invalid_field(self):
# An error should be raised when QuerySet.datetimes() is passed the
# wrong type of field.
- with self.assertRaisesMessage(AssertionError, "'name' isn't a DateField, TimeField, or DateTimeField."):
+ msg = "'name' isn't a DateField, TimeField, or DateTimeField."
+ with self.assertRaisesMessage(TypeError, msg):
Item.objects.datetimes('name', 'month')
def test_ticket22023(self):
@@ -2405,13 +2407,17 @@ class QuerySetSupportsPythonIdioms(TestCase):
def test_slicing_negative_indexing_not_supported_for_single_element(self):
"""hint: inverting your ordering might do what you need"""
- with self.assertRaisesMessage(AssertionError, "Negative indexing is not supported."):
+ msg = 'Negative indexing is not supported.'
+ with self.assertRaisesMessage(ValueError, msg):
Article.objects.all()[-1]
def test_slicing_negative_indexing_not_supported_for_range(self):
"""hint: inverting your ordering might do what you need"""
- with self.assertRaisesMessage(AssertionError, "Negative indexing is not supported."):
+ msg = 'Negative indexing is not supported.'
+ with self.assertRaisesMessage(ValueError, msg):
Article.objects.all()[0:-5]
+ with self.assertRaisesMessage(ValueError, msg):
+ Article.objects.all()[-1:]
def test_invalid_index(self):
msg = 'QuerySet indices must be integers or slices, not str.'