mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Improved error message when index in __getitem__() is invalid.
This commit is contained in:
committed by
Mariusz Felisiak
parent
8323691de0
commit
d89053585e
@@ -2436,6 +2436,11 @@ class QuerySetSupportsPythonIdioms(TestCase):
|
||||
with self.assertRaisesMessage(AssertionError, "Negative indexing is not supported."):
|
||||
Article.objects.all()[0:-5]
|
||||
|
||||
def test_invalid_index(self):
|
||||
msg = 'QuerySet indices must be integers or slices, not str.'
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
Article.objects.all()['foo']
|
||||
|
||||
def test_can_get_number_of_items_in_queryset_using_standard_len(self):
|
||||
self.assertEqual(len(Article.objects.filter(name__exact='Article 1')), 1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user