diff options
author | Nick Pope <nick@nickpope.me.uk> | 2022-02-22 09:29:38 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-22 10:29:38 +0100 |
commit | 847f46e9bf88964484c8b76a10af753ea1018311 (patch) | |
tree | 13aced534cbae373f47cce8fce1444ad0e8e01d3 /tests/basic | |
parent | 7ba6ebe9149ae38257d70100e8bfbfd0da189862 (diff) | |
download | django-847f46e9bf88964484c8b76a10af753ea1018311.tar.gz |
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.
Diffstat (limited to 'tests/basic')
-rw-r--r-- | tests/basic/tests.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/basic/tests.py b/tests/basic/tests.py index 403a761492..7be1595be5 100644 --- a/tests/basic/tests.py +++ b/tests/basic/tests.py @@ -32,12 +32,12 @@ class ModelInstanceCreationTests(TestCase): pub_date=datetime(2005, 7, 28), ) self.assertIsNone(a.id) - self.assertEqual(Article.objects.all().count(), 0) + self.assertEqual(Article.objects.count(), 0) # Save it into the database. You have to call save() explicitly. a.save() self.assertIsNotNone(a.id) - self.assertEqual(Article.objects.all().count(), 1) + self.assertEqual(Article.objects.count(), 1) def test_can_initialize_model_instance_using_positional_arguments(self): """ @@ -199,7 +199,7 @@ class ModelTest(TestCase): for headline in headlines: Article(headline=headline, pub_date=some_pub_date).save() self.assertQuerysetEqual( - Article.objects.all().order_by("headline"), + Article.objects.order_by("headline"), sorted(headlines), transform=lambda a: a.headline, ) |