1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #29135 -- Prevented get_object/list_or_404() from hiding AttributeError raised by QuerySet filtering.

This commit is contained in:
dizballanze
2018-02-17 11:27:46 +03:00
committed by Tim Graham
parent 9b1125bfc7
commit eb002e7892
3 changed files with 21 additions and 6 deletions

View File

@@ -94,3 +94,13 @@ class GetObjectOr404Tests(TestCase):
msg = "First argument to get_list_or_404() must be a Model, Manager, or QuerySet, not 'list'."
with self.assertRaisesMessage(ValueError, msg):
get_list_or_404([Article], title__icontains="Run")
def test_get_object_or_404_queryset_attribute_error(self):
"""AttributeError raised by QuerySet.get() isn't hidden."""
with self.assertRaisesMessage(AttributeError, 'AttributeErrorManager'):
get_object_or_404(Article.attribute_error_objects, id=42)
def test_get_list_or_404_queryset_attribute_error(self):
"""AttributeError raised by QuerySet.filter() isn't hidden."""
with self.assertRaisesMessage(AttributeError, 'AttributeErrorManager'):
get_list_or_404(Article.attribute_error_objects, title__icontains='Run')