Tested invalid QuerySet.order_by() arguments.
This commit is contained in:
parent
f2dc6b3a99
commit
4cfccc713a
|
@ -2946,7 +2946,7 @@ class WhereNodeTest(TestCase):
|
||||||
w.as_sql(compiler, connection)
|
w.as_sql(compiler, connection)
|
||||||
|
|
||||||
|
|
||||||
class IteratorExceptionsTest(TestCase):
|
class QuerySetExceptionTests(TestCase):
|
||||||
def test_iter_exceptions(self):
|
def test_iter_exceptions(self):
|
||||||
qs = ExtraInfo.objects.only('author')
|
qs = ExtraInfo.objects.only('author')
|
||||||
with self.assertRaises(AttributeError):
|
with self.assertRaises(AttributeError):
|
||||||
|
@ -2956,11 +2956,19 @@ class IteratorExceptionsTest(TestCase):
|
||||||
# Test for #19895 - second iteration over invalid queryset
|
# Test for #19895 - second iteration over invalid queryset
|
||||||
# raises errors.
|
# raises errors.
|
||||||
qs = Article.objects.order_by('invalid_column')
|
qs = Article.objects.order_by('invalid_column')
|
||||||
with self.assertRaises(FieldError):
|
msg = "Cannot resolve keyword 'invalid_column' into field."
|
||||||
|
with self.assertRaisesMessage(FieldError, msg):
|
||||||
list(qs)
|
list(qs)
|
||||||
with self.assertRaises(FieldError):
|
with self.assertRaisesMessage(FieldError, msg):
|
||||||
list(qs)
|
list(qs)
|
||||||
|
|
||||||
|
def test_invalid_order_by(self):
|
||||||
|
msg = "Invalid order_by arguments: ['*']"
|
||||||
|
if six.PY2:
|
||||||
|
msg = msg.replace("[", "[u")
|
||||||
|
with self.assertRaisesMessage(FieldError, msg):
|
||||||
|
list(Article.objects.order_by('*'))
|
||||||
|
|
||||||
|
|
||||||
class NullJoinPromotionOrTest(TestCase):
|
class NullJoinPromotionOrTest(TestCase):
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Reference in New Issue