Avoided creating temporary lists for obtaining the first item.

This commit is contained in:
Sergey Fedoseev 2017-07-31 20:02:23 +05:00 committed by Tim Graham
parent 0f905e4b44
commit aadd3aeb2b
8 changed files with 17 additions and 19 deletions

View file

@ -155,7 +155,7 @@ class TestFirstLast(TestCase):
# We know that we've broken the __iter__ method, so the queryset
# should always raise an exception.
with self.assertRaises(IndexError):
IndexErrorArticle.objects.all()[0]
IndexErrorArticle.objects.all()[:10:2]
with self.assertRaises(IndexError):
IndexErrorArticle.objects.all().first()
with self.assertRaises(IndexError):