summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-10-13 20:54:25 -0400
committerTim Graham <timograham@gmail.com>2016-10-13 21:49:19 -0400
commit4cfccc713a8ff91a0d523d74d8b557e89468e84b (patch)
tree600379a11c6acad988c8f57eb21c839bdedde20f
parentf2dc6b3a9947092fd22b4e91523d750cf2f084de (diff)
Tested invalid QuerySet.order_by() arguments.
-rw-r--r--tests/queries/tests.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 993f846bfb..9e65b1a412 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -2946,7 +2946,7 @@ class WhereNodeTest(TestCase):
w.as_sql(compiler, connection)
-class IteratorExceptionsTest(TestCase):
+class QuerySetExceptionTests(TestCase):
def test_iter_exceptions(self):
qs = ExtraInfo.objects.only('author')
with self.assertRaises(AttributeError):
@@ -2956,11 +2956,19 @@ class IteratorExceptionsTest(TestCase):
# Test for #19895 - second iteration over invalid queryset
# raises errors.
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)
- with self.assertRaises(FieldError):
+ with self.assertRaisesMessage(FieldError, msg):
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):
@classmethod