summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authordjango-bot <ops@djangoproject.com>2025-07-22 20:41:41 -0700
committernessita <124304+nessita@users.noreply.github.com>2025-07-23 20:17:55 -0300
commit69a93a88edb56ba47f624dac7a21aacc47ea474f (patch)
treef57507a4435d032493cae40e06ecb254790b67b2 /tests/gis_tests
parent55b0cc21310b76ce4018dd793ba50556eaf0af06 (diff)
Refs #36500 -- Rewrapped long docstrings and block comments via a script.
Rewrapped long docstrings and block comments to 79 characters + newline using script from https://github.com/medmunds/autofix-w505.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/distapp/tests.py17
-rw-r--r--tests/gis_tests/gdal_tests/test_ds.py4
-rw-r--r--tests/gis_tests/gdal_tests/test_envelope.py10
-rw-r--r--tests/gis_tests/gdal_tests/test_geom.py3
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py9
-rw-r--r--tests/gis_tests/gdal_tests/test_srs.py3
-rw-r--r--tests/gis_tests/geo3d/tests.py3
-rw-r--r--tests/gis_tests/geoapp/test_feeds.py3
-rw-r--r--tests/gis_tests/geoapp/test_functions.py20
-rw-r--r--tests/gis_tests/geoapp/test_regress.py14
-rw-r--r--tests/gis_tests/geoapp/tests.py23
-rw-r--r--tests/gis_tests/geogapp/tests.py4
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py35
-rw-r--r--tests/gis_tests/inspectapp/tests.py11
-rw-r--r--tests/gis_tests/layermap/tests.py39
-rw-r--r--tests/gis_tests/relatedapp/tests.py27
-rw-r--r--tests/gis_tests/test_geoforms.py6
-rw-r--r--tests/gis_tests/test_ptr.py6
-rw-r--r--tests/gis_tests/test_spatialrefsys.py3
19 files changed, 149 insertions, 91 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index f5879beeff..f8eae7ba37 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -159,7 +159,7 @@ class DistanceTest(TestCase):
Test distance lookups on geodetic coordinate systems.
"""
# Line is from Canberra to Sydney. Query is for all other cities within
- # a 100km of that line (which should exclude only Hobart & Adelaide).
+ # a 100km of that line (which should exclude only Hobart & # Adelaide).
line = GEOSGeometry("LINESTRING(144.9630 -37.8143,151.2607 -33.8870)", 4326)
dist_qs = AustraliaCity.objects.filter(point__distance_lte=(line, D(km=100)))
expected_cities = [
@@ -221,9 +221,9 @@ class DistanceTest(TestCase):
gq2 = Q(point__distance_gte=(wollongong.point, d2))
qs1 = AustraliaCity.objects.exclude(name="Wollongong").filter(gq1 | gq2)
- # Geodetic distance lookup but telling GeoDjango to use `distance_spheroid`
- # instead (we should get the same results b/c accuracy variance won't matter
- # in this test case).
+ # Geodetic distance lookup but telling GeoDjango to use
+ # `distance_spheroid` instead (we should get the same results b/c
+ # accuracy variance won't matter in this test case).
querysets = [qs1]
if connection.features.has_DistanceSpheroid_function:
gq3 = Q(point__distance_lte=(wollongong.point, d1, "spheroid"))
@@ -532,7 +532,8 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
)
for city, distance in zip(qs, distances):
with self.subTest(city=city, distance=distance):
- # Testing equivalence to within a meter (kilometer on SpatiaLite).
+ # Testing equivalence to within a meter (kilometer on
+ # SpatiaLite).
tol = -3 if connection.ops.spatialite else 0
self.assertAlmostEqual(distance, city.distance.m, tol)
@@ -588,7 +589,8 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
with self.subTest(c=c):
self.assertAlmostEqual(spheroid_distances[i], c.distance.m, tol)
if connection.ops.postgis or connection.ops.spatialite:
- # PostGIS uses sphere-only distances by default, testing these as well.
+ # PostGIS uses sphere-only distances by default, testing these as
+ # well.
qs = (
AustraliaCity.objects.exclude(id=hillsdale.id)
.annotate(distance=Distance("point", hillsdale.point))
@@ -663,7 +665,8 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
@skipUnlessDBFeature("has_Distance_function", "has_Transform_function")
def test_distance_transform(self):
"""
- Test the `Distance` function used with `Transform` on a geographic field.
+ Test the `Distance` function used with `Transform` on a geographic
+ field.
"""
# We'll be using a Polygon (created by buffering the centroid
# of 77005 to 100m) -- which aren't allowed in geographic distance
diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py
index ca7295be00..5bc71acf3e 100644
--- a/tests/gis_tests/gdal_tests/test_ds.py
+++ b/tests/gis_tests/gdal_tests/test_ds.py
@@ -264,8 +264,8 @@ class DataSourceTest(SimpleTestCase):
# Making sure the fields match to an appropriate OFT type.
for k, v in source.fields.items():
- # Making sure we get the proper OGR Field instance, using
- # a string value index for the feature.
+ # Making sure we get the proper OGR Field instance,
+ # using a string value index for the feature.
self.assertIsInstance(feat[k], v)
self.assertIsInstance(feat.fields[0], str)
diff --git a/tests/gis_tests/gdal_tests/test_envelope.py b/tests/gis_tests/gdal_tests/test_envelope.py
index d55aae168b..03882f7a0a 100644
--- a/tests/gis_tests/gdal_tests/test_envelope.py
+++ b/tests/gis_tests/gdal_tests/test_envelope.py
@@ -64,7 +64,10 @@ class EnvelopeTest(unittest.TestCase):
self.assertEqual((-1, -1, 5, 6), self.e)
def test05_expand_to_include_pt_2_tuple(self):
- "Testing Envelope expand_to_include -- point as a single 2-tuple parameter."
+ """
+ Testing Envelope expand_to_include -- point as a single 2-tuple
+ parameter.
+ """
self.e.expand_to_include((10, 10))
self.assertEqual((0, 0, 10, 10), self.e)
self.e.expand_to_include((-10, -10))
@@ -76,7 +79,10 @@ class EnvelopeTest(unittest.TestCase):
self.assertEqual((-1, 0, 5, 7), self.e)
def test06_expand_to_include_extent_4_tuple(self):
- "Testing Envelope expand_to_include -- extent as a single 4-tuple parameter."
+ """
+ Testing Envelope expand_to_include -- extent as a single 4-tuple
+ parameter.
+ """
self.e.expand_to_include((-1, 1, 3, 7))
self.assertEqual((-1, 0, 5, 7), self.e)
diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py
index 919e547511..6951f2f354 100644
--- a/tests/gis_tests/gdal_tests/test_geom.py
+++ b/tests/gis_tests/gdal_tests/test_geom.py
@@ -521,7 +521,8 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
self.assertEqual(3, geom[0].coord_dim)
self.assertEqual(wkt_3d, geom.wkt)
- # Testing binary predicates, `assertIs` is used to check that bool is returned.
+ # Testing binary predicates, `assertIs` is used to check that bool is
+ # returned.
def test_equivalence_regression(self):
"Testing equivalence methods with non-OGRGeometry instances."
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index a5f1edef0b..2c2b77d5cd 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -334,7 +334,8 @@ class GDALRasterTests(SimpleTestCase):
result = rast.bands[0].data()
if numpy:
result = result.flatten().tolist()
- # Band data is equal to zero because no nodata value has been specified.
+ # Band data is equal to zero because no nodata value has been
+ # specified.
self.assertEqual(result, [0] * 4)
def test_raster_metadata_property(self):
@@ -556,7 +557,8 @@ class GDALRasterTests(SimpleTestCase):
],
}
)
- # Warp raster onto a location that does not cover any pixels of the original.
+ # Warp raster onto a location that does not cover any pixels of the
+ # original.
result = source.warp({"origin": (200000, 200000)}).bands[0].data()
if numpy:
result = result.flatten().tolist()
@@ -828,7 +830,8 @@ class GDALBandTests(SimpleTestCase):
band = rs.bands[0]
self.addCleanup(self._remove_aux_file)
- # Setting attributes in write mode raises exception in the _flush method
+ # Setting attributes in write mode raises exception in the _flush
+ # method
with self.assertRaises(GDALException):
setattr(band, "nodata_value", 10)
diff --git a/tests/gis_tests/gdal_tests/test_srs.py b/tests/gis_tests/gdal_tests/test_srs.py
index 62ebc63889..20ad834338 100644
--- a/tests/gis_tests/gdal_tests/test_srs.py
+++ b/tests/gis_tests/gdal_tests/test_srs.py
@@ -110,7 +110,8 @@ srlist = (
(("projcs", 11), "AXIS"),
),
),
- # This is really ESRI format, not WKT -- but the import should work the same
+ # This is really ESRI format, not WKT -- but the import should work the
+ # same
TestSRS(
'LOCAL_CS["Non-Earth (Meter)",LOCAL_DATUM["Local Datum",32767],'
'UNIT["Meter",1],AXIS["X",EAST],AXIS["Y",NORTH]]',
diff --git a/tests/gis_tests/geo3d/tests.py b/tests/gis_tests/geo3d/tests.py
index 7b7e6fea5a..6871a7ba93 100644
--- a/tests/gis_tests/geo3d/tests.py
+++ b/tests/gis_tests/geo3d/tests.py
@@ -226,7 +226,8 @@ class Geo3DTest(Geo3DLoadingHelper, TestCase):
ref_union = GEOSGeometry(ref_ewkt)
union = City3D.objects.aggregate(Union("point"))["point__union"]
self.assertTrue(union.hasz)
- # Ordering of points in the resulting geometry may vary between implementations
+ # Ordering of points in the resulting geometry may vary between
+ # implementations
self.assertEqual({p.ewkt for p in ref_union}, {p.ewkt for p in union})
@skipUnlessDBFeature("supports_3d_functions")
diff --git a/tests/gis_tests/geoapp/test_feeds.py b/tests/gis_tests/geoapp/test_feeds.py
index e247d88535..b927571a29 100644
--- a/tests/gis_tests/geoapp/test_feeds.py
+++ b/tests/gis_tests/geoapp/test_feeds.py
@@ -98,7 +98,8 @@ class GeoFeedTest(TestCase):
items = chan.getElementsByTagName("item")
self.assertEqual(len(items), City.objects.count())
- # Ensuring the geo:lat and geo:lon element was added to each item in the feed.
+ # Ensuring the geo:lat and geo:lon element was added to each item in
+ # the feed.
for item in items:
self.assertChildNodes(
item, ["title", "link", "description", "guid", "geo:lat", "geo:lon"]
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 047d6948b1..70c462a78e 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -210,8 +210,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
# SELECT AsSVG(geoapp_city.point, 0, 8) FROM geoapp_city
# WHERE name = 'Pueblo';
svg1 = 'cx="-104.609252" cy="-38.255001"'
- # Even though relative, only one point so it's practically the same except for
- # the 'c' letter prefix on the x,y values.
+ # Even though relative, only one point so it's practically the same
+ # except for the 'c' letter prefix on the x,y values.
svg2 = svg1.replace("c", "")
self.assertEqual(
svg1,
@@ -463,7 +463,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
@skipUnlessDBFeature("has_Area_function")
def test_area_with_regular_aggregate(self):
- # Create projected country objects, for this test to work on all backends.
+ # Create projected country objects, for this test to work on all
+ # backends.
for c in Country.objects.all():
CountryWebMercator.objects.create(
name=c.name, mpoly=c.mpoly.transform(3857, clone=True)
@@ -684,7 +685,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
@skipUnlessDBFeature("has_SnapToGrid_function")
def test_snap_to_grid(self):
- # Let's try and break snap_to_grid() with bad combinations of arguments.
+ # Let's try and break snap_to_grid() with bad combinations of
+ # arguments.
for bad_args in ((), range(3), range(5)):
with self.assertRaises(ValueError):
Country.objects.annotate(snap=functions.SnapToGrid("mpoly", *bad_args))
@@ -692,8 +694,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
with self.assertRaises(TypeError):
Country.objects.annotate(snap=functions.SnapToGrid("mpoly", *bad_args))
- # Boundary for San Marino, courtesy of Bjorn Sandvik of thematicmapping.org
- # from the world borders dataset he provides.
+ # Boundary for San Marino, courtesy of Bjorn Sandvik of
+ # thematicmapping.org from the world borders dataset he provides.
wkt = (
"MULTIPOLYGON(((12.41580 43.95795,12.45055 43.97972,12.45389 43.98167,"
"12.46250 43.98472,12.47167 43.98694,12.49278 43.98917,"
@@ -817,9 +819,9 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
)
if connection.ops.oracle:
- # Should be able to execute the queries; however, they won't be the same
- # as GEOS (because Oracle doesn't use GEOS internally like PostGIS or
- # SpatiaLite).
+ # Should be able to execute the queries; however, they won't be the
+ # same as GEOS (because Oracle doesn't use GEOS internally like
+ # PostGIS or SpatiaLite).
return
for c in qs:
self.assertTrue(c.mpoly.difference(geom).equals(c.difference))
diff --git a/tests/gis_tests/geoapp/test_regress.py b/tests/gis_tests/geoapp/test_regress.py
index 9a9226f341..8ac0ed3049 100644
--- a/tests/gis_tests/geoapp/test_regress.py
+++ b/tests/gis_tests/geoapp/test_regress.py
@@ -67,7 +67,10 @@ class GeoRegressionTests(TestCase):
)
def test_empty_count(self):
- "Testing that PostGISAdapter.__eq__ does check empty strings. See #13670."
+ """
+ Testing that PostGISAdapter.__eq__ does check empty strings. See
+ #13670.
+ """
# contrived example, but need a geo lookup paired with an id__in lookup
pueblo = City.objects.get(name="Pueblo")
state = State.objects.filter(poly__contains=pueblo.point)
@@ -78,7 +81,10 @@ class GeoRegressionTests(TestCase):
@skipUnlessDBFeature("allows_group_by_lob")
def test_defer_or_only_with_annotate(self):
- "Regression for #16409. Make sure defer() and only() work with annotate()"
+ """
+ Regression for #16409. Make sure defer() and only() work with
+ annotate()
+ """
self.assertIsInstance(
list(City.objects.annotate(Count("point")).defer("name")), list
)
@@ -87,7 +93,9 @@ class GeoRegressionTests(TestCase):
)
def test_boolean_conversion(self):
- "Testing Boolean value conversion with the spatial backend, see #15169."
+ """
+ Testing Boolean value conversion with the spatial backend, see #15169.
+ """
t1 = Truth.objects.create(val=True)
t2 = Truth.objects.create(val=False)
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 395043e832..84138eb431 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -367,14 +367,15 @@ class GeoLookupTest(TestCase):
"Testing the 'left' and 'right' lookup types."
# Left: A << B => true if xmax(A) < xmin(B)
# Right: A >> B => true if xmin(A) > xmax(B)
- # See: BOX2D_left() and BOX2D_right() in lwgeom_box2dfloat4.c in PostGIS source.
+ # See: BOX2D_left() and BOX2D_right() in lwgeom_box2dfloat4.c in
+ # PostGIS source.
# Getting the borders for Colorado & Kansas
co_border = State.objects.get(name="Colorado").poly
ks_border = State.objects.get(name="Kansas").poly
- # Note: Wellington has an 'X' value of 174, so it will not be considered
- # to the left of CO.
+ # Note: Wellington has an 'X' value of 174, so it will not be
+ # considered to the left of CO.
# These cities should be strictly to the right of the CO border.
cities = [
@@ -397,7 +398,8 @@ class GeoLookupTest(TestCase):
for c in qs:
self.assertIn(c.name, cities)
- # Note: Wellington has an 'X' value of 174, so it will not be considered
+ # Note: Wellington has an 'X' value of 174, so it will not be
+ # considered
# to the left of CO.
vic = City.objects.get(point__left=co_border)
self.assertEqual("Victoria", vic.name)
@@ -441,7 +443,8 @@ class GeoLookupTest(TestCase):
nullqs = State.objects.filter(poly__isnull=True)
validqs = State.objects.filter(poly__isnull=False)
- # Puerto Rico should be NULL (it's a commonwealth unincorporated territory)
+ # Puerto Rico should be NULL (it's a commonwealth unincorporated
+ # territory)
self.assertEqual(1, len(nullqs))
self.assertEqual("Puerto Rico", nullqs[0].name)
# GeometryField=None is an alias for __isnull=True.
@@ -535,8 +538,8 @@ class GeoLookupTest(TestCase):
@skipUnlessDBFeature("supports_relate_lookup")
def test_relate_lookup(self):
"Testing the 'relate' lookup type."
- # To make things more interesting, we will have our Texas reference point in
- # different SRIDs.
+ # To make things more interesting, we will have our Texas reference
+ # point in different SRIDs.
pnt1 = fromstr("POINT (649287.0363174 4177429.4494686)", srid=2847)
pnt2 = fromstr("POINT(-98.4919715741052 29.4333344025053)", srid=4326)
@@ -653,7 +656,8 @@ class GeoQuerySetTest(TestCase):
# SELECT ST_extent(point)
# FROM geoapp_city
# WHERE (name='Houston' or name='Dallas');`
- # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984 32.7820587158203)
+ # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984
+ # 32.7820587158203)
expected = (
-96.8016128540039,
29.7633724212646,
@@ -710,7 +714,8 @@ class GeoQuerySetTest(TestCase):
Testing the `Union` aggregate.
"""
tx = Country.objects.get(name="Texas").mpoly
- # Houston, Dallas -- Ordering may differ depending on backend or GEOS version.
+ # Houston, Dallas -- Ordering may differ depending on backend or GEOS
+ # version.
union = GEOSGeometry("MULTIPOINT(-96.801611 32.782057,-95.363151 29.763374)")
qs = City.objects.filter(point__within=tx)
with self.assertRaises(ValueError):
diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py
index cb783b9465..229ce88586 100644
--- a/tests/gis_tests/geogapp/tests.py
+++ b/tests/gis_tests/geogapp/tests.py
@@ -147,8 +147,8 @@ class GeographyFunctionTests(FuncTestMixin, TestCase):
ref_dists = [0, 4899.68, 8081.30, 9115.15]
elif connection.ops.spatialite:
if connection.ops.spatial_version < (5,):
- # SpatiaLite < 5 returns non-zero distance for polygons and points
- # covered by that polygon.
+ # SpatiaLite < 5 returns non-zero distance for polygons and
+ # points covered by that polygon.
ref_dists = [326.61, 4899.68, 8081.30, 9115.15]
else:
ref_dists = [0, 4899.68, 8081.30, 9115.15]
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index ac67d6ccad..5ec997556b 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -280,7 +280,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
("POINT EMPTY", "LINESTRING EMPTY", False),
# Empty inputs of different dimensions are not equals_identical.
("POINT EMPTY", "POINT Z EMPTY", False),
- # Non-empty inputs of different dimensions are not equals_identical.
+ # Non-empty inputs of different dimensions are not
+ # equals_identical.
("POINT Z (1 2 3)", "POINT M (1 2 3)", False),
("POINT ZM (1 2 3 4)", "POINT Z (1 2 3)", False),
# Inputs with different structure are not equals_identical.
@@ -371,7 +372,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self.assertEqual(pnt, fromstr(p.wkt))
self.assertIs(pnt == prev, False) # Use assertIs() to test __eq__.
- # Making sure that the point's X, Y components are what we expect
+ # Making sure that the point's X, Y components are what we
+ # expect
self.assertAlmostEqual(p.x, pnt.tuple[0], 9)
self.assertAlmostEqual(p.y, pnt.tuple[1], 9)
@@ -753,12 +755,14 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
# These tests are needed to ensure sanity with writable geometries.
- # Getting a polygon with interior rings, and pulling out the interior rings
+ # Getting a polygon with interior rings, and pulling out the interior
+ # rings
poly = fromstr(self.geometries.polygons[1].wkt)
ring1 = poly[0]
ring2 = poly[1]
- # These deletes should be 'harmless' since they are done on child geometries
+ # These deletes should be 'harmless' since they are done on child
+ # geometries
del ring1
del ring2
ring1 = poly[0]
@@ -776,7 +780,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
for p in self.geometries.polygons:
with self.subTest(p=p):
if p.ext_ring_cs:
- # Constructing the polygon and getting the coordinate sequence
+ # Constructing the polygon and getting the coordinate
+ # sequence
poly = fromstr(p.wkt)
cs = poly.exterior_ring.coord_seq
@@ -791,7 +796,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
for expected_value, coord_sequence in zip(p.ext_ring_cs, cs):
self.assertEqual(expected_value, coord_sequence)
- # Construct the test value to set the coordinate sequence with
+ # Construct the test value to set the coordinate
+ # sequence with
if len(expected_value) == 2:
tset = (5, 23)
else:
@@ -956,8 +962,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
# Now assuring that each point in the buffer is almost equal
for exp_ring, buf_ring in zip(exp_buf, buf, strict=True):
for exp_point, buf_point in zip(exp_ring, buf_ring, strict=True):
- # Asserting the X, Y of each point are almost equal (due to
- # floating point imprecision).
+ # Asserting the X, Y of each point are almost equal
+ # (due to floating point imprecision).
self.assertAlmostEqual(exp_point[0], buf_point[0], 9)
self.assertAlmostEqual(exp_point[1], buf_point[1], 9)
@@ -1064,11 +1070,13 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
"initialize to LinearRings"
)
with self.subTest(p=p):
- # Should only be able to use __setitem__ with LinearRing geometries.
+ # Should only be able to use __setitem__ with LinearRing
+ # geometries.
with self.assertRaisesMessage(TypeError, msg):
poly.__setitem__(0, LineString((1, 1), (2, 2)))
- # Construct the new shell by adding 500 to every point in the old shell.
+ # Construct the new shell by adding 500 to every point in the
+ # old shell.
shell_tup = poly.shell.tuple
new_coords = []
for point in shell_tup:
@@ -1615,8 +1623,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
def test_subclassing(self):
"""
- GEOSGeometry subclass may itself be subclassed without being forced-cast
- to the parent class during `__init__`.
+ GEOSGeometry subclass may itself be subclassed without being
+ forced-cast to the parent class during `__init__`.
"""
class ExtendedPolygon(Polygon):
@@ -1629,7 +1637,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
ext_poly = ExtendedPolygon(((0, 0), (0, 1), (1, 1), (0, 0)), data=3)
self.assertEqual(type(ext_poly), ExtendedPolygon)
- # ExtendedPolygon.__str__ should be called (instead of Polygon.__str__).
+ # ExtendedPolygon.__str__ should be called (instead of
+ # Polygon.__str__).
self.assertEqual(
str(ext_poly), "EXT_POLYGON - data: 3 - POLYGON ((0 0, 0 1, 1 1, 0 0))"
)
diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py
index ca5d5214dd..00a3507b59 100644
--- a/tests/gis_tests/inspectapp/tests.py
+++ b/tests/gis_tests/inspectapp/tests.py
@@ -118,8 +118,8 @@ class OGRInspectTest(SimpleTestCase):
self.skipTest("Unable to setup an OGR connection to your database")
try:
- # Writing shapefiles via GDAL currently does not support writing OGRTime
- # fields, so we need to actually use a database
+ # Writing shapefiles via GDAL currently does not support writing
+ # OGRTime fields, so we need to actually use a database
model_def = ogrinspect(
ogr_db,
"Measurement",
@@ -143,7 +143,8 @@ class OGRInspectTest(SimpleTestCase):
# The ordering of model fields might vary depending on several factors
# (version of GDAL, etc.).
if connection.vendor == "sqlite" and GDAL_VERSION < (3, 4):
- # SpatiaLite introspection is somewhat lacking on GDAL < 3.4 (#29461).
+ # SpatiaLite introspection is somewhat lacking on GDAL < 3.4
+ # (#29461).
self.assertIn(" f_decimal = models.CharField(max_length=0)", model_def)
else:
self.assertIn(
@@ -205,8 +206,8 @@ def get_ogr_db_string():
"""
db = connections.settings["default"]
- # Map from the django backend into the OGR driver name and database identifier
- # https://gdal.org/drivers/vector/
+ # Map from the django backend into the OGR driver name and database
+ # identifier https://gdal.org/drivers/vector/
#
# TODO: Support Oracle (OCI).
drivers = {
diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py
index c5ed84d39c..c590defbd0 100644
--- a/tests/gis_tests/layermap/tests.py
+++ b/tests/gis_tests/layermap/tests.py
@@ -130,7 +130,8 @@ class LayerMapTest(TestCase):
self.assertEqual(Decimal(str(feat["Length"])), istate.length)
elif feat.fid == 1:
# Everything but the first two decimal digits were truncated,
- # because the Interstate model's `length` field has decimal_places=2.
+ # because the Interstate model's `length` field has
+ # decimal_places=2.
self.assertAlmostEqual(feat.get("Length"), float(istate.length), 2)
for p1, p2 in zip(feat.geom, istate.path):
@@ -138,7 +139,9 @@ class LayerMapTest(TestCase):
self.assertAlmostEqual(p1[1], p2[1], 6)
def county_helper(self, county_feat=True):
- "Helper function for ensuring the integrity of the mapped County models."
+ """
+ Helper function for ensuring the integrity of the mapped County models.
+ """
for name, n, st in zip(NAMES, NUMS, STATES):
# Should only be one record b/c of `unique` keyword.
c = County.objects.get(name=name)
@@ -157,10 +160,12 @@ class LayerMapTest(TestCase):
"""
# All the following should work.
- # Telling LayerMapping that we want no transformations performed on the data.
+ # Telling LayerMapping that we want no transformations performed on the
+ # data.
lm = LayerMapping(County, co_shp, co_mapping, transform=False)
- # Specifying the source spatial reference system via the `source_srs` keyword.
+ # Specifying the source spatial reference system via the `source_srs`
+ # keyword.
lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269)
lm = LayerMapping(County, co_shp, co_mapping, source_srs="NAD83")
@@ -179,13 +184,14 @@ class LayerMapTest(TestCase):
with self.assertRaises(e):
LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)
- # No source reference system defined in the shapefile, should raise an error.
+ # No source reference system defined in the shapefile, should raise an
+ # error.
if connection.features.supports_transform:
with self.assertRaises(LayerMapError):
LayerMapping(County, co_shp, co_mapping)
- # Passing in invalid ForeignKey mapping parameters -- must be a dictionary
- # mapping for the model the ForeignKey points to.
+ # Passing in invalid ForeignKey mapping parameters -- must be a
+ # dictionary mapping for the model the ForeignKey points to.
bad_fk_map1 = copy(co_mapping)
bad_fk_map1["state"] = "name"
bad_fk_map2 = copy(co_mapping)
@@ -195,9 +201,9 @@ class LayerMapTest(TestCase):
with self.assertRaises(LayerMapError):
LayerMapping(County, co_shp, bad_fk_map2, transform=False)
- # There exist no State models for the ForeignKey mapping to work -- should raise
- # a MissingForeignKey exception (this error would be ignored if the `strict`
- # keyword is not set).
+ # There exist no State models for the ForeignKey mapping to work --
+ # should raise a MissingForeignKey exception (this error would be
+ # ignored if the `strict` keyword is not set).
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique="name")
with self.assertRaises(MissingForeignKey):
lm.save(silent=True, strict=True)
@@ -208,12 +214,13 @@ class LayerMapTest(TestCase):
)
# If a mapping is specified as a collection, all OGR fields that
- # are not collections will be converted into them. For example,
- # a Point column would be converted to MultiPoint. Other things being done
+ # are not collections will be converted into them. For example, a Point
+ # column would be converted to MultiPoint. Other things being done
# w/the keyword args:
# `transform=False`: Specifies that no transform is to be done; this
- # has the effect of ignoring the spatial reference check (because the
- # county shapefile does not have implicit spatial reference info).
+ # has the effect of ignoring the spatial reference check (because
+ # the county shapefile does not have implicit spatial reference
+ # info).
#
# `unique='name'`: Creates models on the condition that they have
# unique county names; geometries from each feature however will be
@@ -223,8 +230,8 @@ class LayerMapTest(TestCase):
lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique="name")
lm.save(silent=True, strict=True)
- # A reference that doesn't use the unique keyword; a new database record will
- # created for each polygon.
+ # A reference that doesn't use the unique keyword; a new database
+ # record will created for each polygon.
lm = LayerMapping(CountyFeat, co_shp, cofeat_mapping, transform=False)
lm.save(silent=True, strict=True)
diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py
index 86d7488341..34dc2bba15 100644
--- a/tests/gis_tests/relatedapp/tests.py
+++ b/tests/gis_tests/relatedapp/tests.py
@@ -51,7 +51,8 @@ class RelatedGeoModelTest(TestCase):
e3 = aggs["location__point__extent"]
# The tolerance value is to four decimal places because of differences
- # between the Oracle and PostGIS spatial backends on the extent calculation.
+ # between the Oracle and PostGIS spatial backends on the extent
+ # calculation.
tol = 4
for ref, e in [(all_extent, e1), (txpa_extent, e2), (all_extent, e3)]:
for ref_val, e_val in zip(ref, e):
@@ -85,8 +86,8 @@ class RelatedGeoModelTest(TestCase):
p5 = Point(-95.363151, 29.763374)
# The second union aggregate is for a union
- # query that includes limiting information in the WHERE clause (in other
- # words a `.filter()` precedes the call to `.aggregate(Union()`).
+ # query that includes limiting information in the WHERE clause (in
+ # other words a `.filter()` precedes the call to `.aggregate(Union()`).
ref_u1 = MultiPoint(p1, p2, p4, p5, p3, srid=4326)
ref_u2 = MultiPoint(p2, p3, srid=4326)
@@ -187,8 +188,8 @@ class RelatedGeoModelTest(TestCase):
# Incrementing through each of the models, dictionaries, and tuples
# returned by each QuerySet.
for m, d, t in zip(gqs, gvqs, gvlqs):
- # The values should be Geometry objects and not raw strings returned
- # by the spatial database.
+ # The values should be Geometry objects and not raw strings
+ # returned by the spatial database.
self.assertIsInstance(d["point"], GEOSGeometry)
self.assertIsInstance(t[1], GEOSGeometry)
self.assertEqual(m.point, d["point"])
@@ -208,7 +209,10 @@ class RelatedGeoModelTest(TestCase):
self.assertEqual(loc.point, def_loc.point)
def test09_pk_relations(self):
- "Ensuring correct primary key column is selected across relations. See #10757."
+ """
+ Ensuring correct primary key column is selected across relations. See
+ #10757.
+ """
# The expected ID values -- notice the last two location IDs
# are out of order. Dallas and Houston have location IDs that differ
# from their PKs -- this is done to ensure that the related location
@@ -426,13 +430,16 @@ class RelatedGeoModelTest(TestCase):
select_related on the related name manager of a unique FK.
"""
qs = Article.objects.select_related("author__article")
- # This triggers TypeError when `get_default_columns` has no `local_only`
- # keyword. The TypeError is swallowed if QuerySet is actually
- # evaluated as list generation swallows TypeError in CPython.
+ # This triggers TypeError when `get_default_columns` has no
+ # `local_only` keyword. The TypeError is swallowed if QuerySet is
+ # actually evaluated as list generation swallows TypeError in CPython.
str(qs.query)
def test16_annotated_date_queryset(self):
- "Ensure annotated date querysets work if spatial backend is used. See #14648."
+ """
+ Ensure annotated date querysets work if spatial backend is used. See
+ #14648.
+ """
birth_years = [
dt.year
for dt in list(
diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py
index 23f94edd0e..2a1f585906 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -34,7 +34,8 @@ class GeometryFieldTest(SimpleTestCase):
xform_geom = GEOSGeometry(
"POINT (951640.547328465 4219369.26171664)", srid=32140
)
- # The cleaned geometry is transformed to 32140 (the widget map_srid is 3857).
+ # The cleaned geometry is transformed to 32140 (the widget map_srid is
+ # 3857).
cleaned_geom = fld.clean(
"SRID=3857;POINT (-10615777.40976205 3473169.895707852)"
)
@@ -73,7 +74,8 @@ class GeometryFieldTest(SimpleTestCase):
GEOSGeometry("POINT(5 23)", srid=pnt_fld.widget.map_srid),
pnt_fld.clean("POINT(5 23)"),
)
- # a WKT for any other geom_type will be properly transformed by `to_python`
+ # a WKT for any other geom_type will be properly transformed by
+ # `to_python`
self.assertEqual(
GEOSGeometry("LINESTRING(0 0, 1 1)", srid=pnt_fld.widget.map_srid),
pnt_fld.to_python("LINESTRING(0 0, 1 1)"),
diff --git a/tests/gis_tests/test_ptr.py b/tests/gis_tests/test_ptr.py
index a09679f5b9..cfe58ae1a8 100644
--- a/tests/gis_tests/test_ptr.py
+++ b/tests/gis_tests/test_ptr.py
@@ -37,9 +37,9 @@ class CPointerBaseTests(SimpleTestCase):
fg.ptr
# Anything that's either not None or the acceptable pointer type
- # results in a TypeError when trying to assign it to the `ptr` property.
- # Thus, memory addresses (integers) and pointers of the incorrect type
- # (in `bad_ptrs`) aren't allowed.
+ # results in a TypeError when trying to assign it to the `ptr`
+ # property. Thus, memory addresses (integers) and pointers of the
+ # incorrect type (in `bad_ptrs`) aren't allowed.
bad_ptrs = (5, ctypes.c_char_p(b"foobar"))
for bad_ptr in bad_ptrs:
for fg in (fg1, fg2):
diff --git a/tests/gis_tests/test_spatialrefsys.py b/tests/gis_tests/test_spatialrefsys.py
index d936ac8c89..e49db86d50 100644
--- a/tests/gis_tests/test_spatialrefsys.py
+++ b/tests/gis_tests/test_spatialrefsys.py
@@ -10,7 +10,8 @@ test_srs = (
"srid": 4326,
"auth_name": ("EPSG", True),
"auth_srid": 4326,
- # Only the beginning, because there are differences depending on installed libs
+ # Only the beginning, because there are differences depending on
+ # installed libs
"srtext": 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
"proj_re": (
r"\+proj=longlat (\+datum=WGS84 |\+towgs84=0,0,0,0,0,0,0 )\+no_defs ?"