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/gis_tests | |
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/gis_tests')
-rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 2 | ||||
-rw-r--r-- | tests/gis_tests/geoapp/test_serializers.py | 6 | ||||
-rw-r--r-- | tests/gis_tests/geoapp/tests.py | 8 | ||||
-rw-r--r-- | tests/gis_tests/relatedapp/tests.py | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index b632d2cf61..e1a66d573e 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -690,7 +690,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase): ) def test_diff_intersection_union(self): geom = Point(5, 23, srid=4326) - qs = Country.objects.all().annotate( + qs = Country.objects.annotate( difference=functions.Difference("mpoly", geom), sym_difference=functions.SymDifference("mpoly", geom), union=functions.Union("mpoly", geom), diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py index a67a4f16db..44066daee9 100644 --- a/tests/gis_tests/geoapp/test_serializers.py +++ b/tests/gis_tests/geoapp/test_serializers.py @@ -21,12 +21,12 @@ class GeoJSONSerializerTests(TestCase): self.assertIn("geojson", public_formats) def test_serialization_base(self): - geojson = serializers.serialize("geojson", City.objects.all().order_by("name")) + geojson = serializers.serialize("geojson", City.objects.order_by("name")) geodata = json.loads(geojson) self.assertEqual(len(geodata["features"]), len(City.objects.all())) self.assertEqual(geodata["features"][0]["geometry"]["type"], "Point") self.assertEqual(geodata["features"][0]["properties"]["name"], "Chicago") - first_city = City.objects.all().order_by("name").first() + first_city = City.objects.order_by("name").first() self.assertEqual(geodata["features"][0]["properties"]["pk"], str(first_city.pk)) def test_geometry_field_option(self): @@ -81,7 +81,7 @@ class GeoJSONSerializerTests(TestCase): def test_srid_option(self): geojson = serializers.serialize( - "geojson", City.objects.all().order_by("name"), srid=2847 + "geojson", City.objects.order_by("name"), srid=2847 ) geodata = json.loads(geojson) coordinates = geodata["features"][0]["geometry"]["coordinates"] diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py index 6acf6e150b..0a71639c84 100644 --- a/tests/gis_tests/geoapp/tests.py +++ b/tests/gis_tests/geoapp/tests.py @@ -217,7 +217,7 @@ class GeoModelTest(TestCase): Test a dumpdata/loaddata cycle with geographic data. """ out = StringIO() - original_data = list(City.objects.all().order_by("name")) + original_data = list(City.objects.order_by("name")) call_command("dumpdata", "geoapp.City", stdout=out) result = out.getvalue() houston = City.objects.get(name="Houston") @@ -228,7 +228,7 @@ class GeoModelTest(TestCase): tmp.write(result) tmp.seek(0) call_command("loaddata", tmp.name, verbosity=0) - self.assertEqual(original_data, list(City.objects.all().order_by("name"))) + self.assertEqual(original_data, list(City.objects.order_by("name"))) @skipUnlessDBFeature("supports_empty_geometries") def test_empty_geometries(self): @@ -623,7 +623,7 @@ class GeoQuerySetTest(TestCase): """ Testing if extent supports limit. """ - extent1 = City.objects.all().aggregate(Extent("point"))["point__extent"] + extent1 = City.objects.aggregate(Extent("point"))["point__extent"] extent2 = City.objects.all()[:3].aggregate(Extent("point"))["point__extent"] self.assertNotEqual(extent1, extent2) @@ -633,7 +633,7 @@ class GeoQuerySetTest(TestCase): """ if not connection.features.supports_make_line_aggr: with self.assertRaises(NotSupportedError): - City.objects.all().aggregate(MakeLine("point")) + City.objects.aggregate(MakeLine("point")) return # MakeLine on an inappropriate field returns simply None diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py index d93fe3b76b..52abf7ba4b 100644 --- a/tests/gis_tests/relatedapp/tests.py +++ b/tests/gis_tests/relatedapp/tests.py @@ -108,7 +108,7 @@ class RelatedGeoModelTest(TestCase): select_related on a query over a model with an FK to a model subclass. """ # Regression test for #9752. - list(DirectoryEntry.objects.all().select_related()) + list(DirectoryEntry.objects.select_related()) def test06_f_expressions(self): "Testing F() expressions on GeometryFields." |