From 847f46e9bf88964484c8b76a10af753ea1018311 Mon Sep 17 00:00:00 2001 From: Nick Pope Date: Tue, 22 Feb 2022 09:29:38 +0000 Subject: Removed redundant QuerySet.all() calls in docs and tests. Most QuerySet methods are mapped onto the Manager and, in general, it isn't necessary to call .all() on the manager. --- tests/admin_views/test_actions.py | 2 +- tests/admin_views/tests.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/admin_views') diff --git a/tests/admin_views/test_actions.py b/tests/admin_views/test_actions.py index ec690f5692..0c209019f3 100644 --- a/tests/admin_views/test_actions.py +++ b/tests/admin_views/test_actions.py @@ -190,7 +190,7 @@ class AdminActionsTest(TestCase): ) # SubscriberAdmin.delete_queryset() sets overridden to True. self.assertIs(SubscriberAdmin.overridden, True) - self.assertEqual(Subscriber.objects.all().count(), 0) + self.assertEqual(Subscriber.objects.count(), 0) def test_delete_selected_uses_get_deleted_objects(self): """The delete_selected action uses ModelAdmin.get_deleted_objects().""" diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index 4d26ad7023..0e4a6b10be 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -1478,7 +1478,7 @@ class AdminCustomTemplateTests(AdminViewBasicTestCase): self.assertRedirects( post, reverse("admin:admin_views_customarticle_changelist") ) - self.assertEqual(CustomArticle.objects.all().count(), 1) + self.assertEqual(CustomArticle.objects.count(), 1) article_pk = CustomArticle.objects.all()[0].pk # Test custom delete, change, and object history templates @@ -5668,7 +5668,7 @@ class SeleniumTests(AdminSeleniumTestCase): # Save and check that everything is properly stored in the database with self.wait_page_loaded(): self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click() - self.assertEqual(MainPrepopulated.objects.all().count(), 1) + self.assertEqual(MainPrepopulated.objects.count(), 1) MainPrepopulated.objects.get( name=" the mAin nÀMë and it's awεšomeıııİ", pubdate="2012-02-18", @@ -5677,7 +5677,7 @@ class SeleniumTests(AdminSeleniumTestCase): slug2="option-two-the-main-name-and-its-awesomeiiii", slug3="the-main-nàmë-and-its-awεšomeıııi", ) - self.assertEqual(RelatedPrepopulated.objects.all().count(), 6) + self.assertEqual(RelatedPrepopulated.objects.count(), 6) RelatedPrepopulated.objects.get( name=" here is a sŤāÇkeð inline ! ", pubdate="2011-12-17", -- cgit v1.3