summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-04 08:08:27 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-02-07 20:37:05 +0100
commit7119f40c9881666b6f9b5cf7df09ee1d21cc8344 (patch)
treefa50869f5614295f462d9bf77fec59365c621609 /tests/gis_tests
parent9c19aff7c7561e3a82978a272ecdaad40dda5c00 (diff)
downloaddjango-7119f40c9881666b6f9b5cf7df09ee1d21cc8344.tar.gz
Refs #33476 -- Refactored code to strictly match 88 characters line length.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/distapp/tests.py45
-rw-r--r--tests/gis_tests/gdal_tests/test_ds.py7
-rw-r--r--tests/gis_tests/gdal_tests/test_geom.py3
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py15
-rw-r--r--tests/gis_tests/gdal_tests/test_srs.py30
-rw-r--r--tests/gis_tests/geoadmin_deprecated/tests.py14
-rw-r--r--tests/gis_tests/geoapp/test_functions.py24
-rw-r--r--tests/gis_tests/geoapp/tests.py10
-rw-r--r--tests/gis_tests/geogapp/tests.py5
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py6
-rw-r--r--tests/gis_tests/inspectapp/tests.py6
-rw-r--r--tests/gis_tests/layermap/models.py3
-rw-r--r--tests/gis_tests/layermap/tests.py5
-rw-r--r--tests/gis_tests/relatedapp/tests.py18
-rw-r--r--tests/gis_tests/test_geoforms.py3
-rw-r--r--tests/gis_tests/test_spatialrefsys.py14
16 files changed, 142 insertions, 66 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index a28a698a81..84b58b345b 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -128,9 +128,6 @@ class DistanceTest(TestCase):
@skipUnlessDBFeature("supports_distances_lookups")
def test_distance_lookups(self):
- """
- Test the `distance_lt`, `distance_gt`, `distance_lte`, and `distance_gte` lookup types.
- """
# Retrieving the cities within a 20km 'donut' w/a 7km radius 'hole'
# (thus, Houston and Southside place will be excluded as tested in
# the `test02_dwithin` above).
@@ -316,7 +313,10 @@ class DistanceTest(TestCase):
def test_mysql_geodetic_distance_error(self):
if not connection.ops.mysql:
self.skipTest("This is a MySQL-specific test.")
- msg = "Only numeric values of degree units are allowed on geodetic distance queries."
+ msg = (
+ "Only numeric values of degree units are allowed on geodetic distance "
+ "queries."
+ )
with self.assertRaisesMessage(ValueError, msg):
AustraliaCity.objects.filter(
point__distance_lte=(Point(0, 0), D(m=100))
@@ -440,7 +440,10 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
lagrange = GEOSGeometry("POINT(-96.876369 29.905320)", 4326)
# Reference distances in feet and in meters. Got these values from
# using the provided raw SQL statements.
- # SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 32140))
+ # SELECT ST_Distance(
+ # point,
+ # ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 32140)
+ # )
# FROM distapp_southtexascity;
m_distances = [
147075.069813,
@@ -453,7 +456,10 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
165337.758878,
139196.085105,
]
- # SELECT ST_Distance(point, ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 2278))
+ # SELECT ST_Distance(
+ # point,
+ # ST_Transform(ST_GeomFromText('POINT(-96.876369 29.905320)', 4326), 2278)
+ # )
# FROM distapp_southtexascityft;
ft_distances = [
482528.79154625,
@@ -494,7 +500,10 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
ls = LineString(((150.902, -34.4245), (150.87, -34.5789)), srid=4326)
# Reference query:
- # SELECT ST_distance_sphere(point, ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326))
+ # SELECT ST_distance_sphere(
+ # point,
+ # ST_GeomFromText('LINESTRING(150.9020 -34.4245,150.8700 -34.5789)', 4326)
+ # )
# FROM distapp_australiacity ORDER BY name;
distances = [
1120954.92533513,
@@ -523,9 +532,16 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
tol = 2 if connection.ops.oracle else 4
# Got the reference distances using the raw SQL statements:
- # SELECT ST_distance_spheroid(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326),
- # 'SPHEROID["WGS 84",6378137.0,298.257223563]') FROM distapp_australiacity WHERE (NOT (id = 11));
- # SELECT ST_distance_sphere(point, ST_GeomFromText('POINT(151.231341 -33.952685)', 4326))
+ # SELECT ST_distance_spheroid(
+ # point,
+ # ST_GeomFromText('POINT(151.231341 -33.952685)', 4326),
+ # 'SPHEROID["WGS 84",6378137.0,298.257223563]'
+ # )
+ # FROM distapp_australiacity WHERE (NOT (id = 11));
+ # SELECT ST_distance_sphere(
+ # point,
+ # ST_GeomFromText('POINT(151.231341 -33.952685)', 4326)
+ # )
# FROM distapp_australiacity WHERE (NOT (id = 11)); st_distance_sphere
spheroid_distances = [
60504.0628957201,
@@ -688,8 +704,10 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
Test the `Length` function.
"""
# Reference query (should use `length_spheroid`).
- # SELECT ST_length_spheroid(ST_GeomFromText('<wkt>', 4326) 'SPHEROID["WGS 84",6378137,298.257223563,
- # AUTHORITY["EPSG","7030"]]');
+ # SELECT ST_length_spheroid(
+ # ST_GeomFromText('<wkt>', 4326)
+ # 'SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]]'
+ # );
len_m1 = 473504.769553813
len_m2 = 4617.668
@@ -723,7 +741,8 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase):
Test the `Perimeter` function.
"""
# Reference query:
- # SELECT ST_Perimeter(distapp_southtexaszipcode.poly) FROM distapp_southtexaszipcode;
+ # SELECT ST_Perimeter(distapp_southtexaszipcode.poly)
+ # FROM distapp_southtexaszipcode;
perim_m = [
18404.3550889361,
15627.2108551001,
diff --git a/tests/gis_tests/gdal_tests/test_ds.py b/tests/gis_tests/gdal_tests/test_ds.py
index fae11cfea9..30c011f126 100644
--- a/tests/gis_tests/gdal_tests/test_ds.py
+++ b/tests/gis_tests/gdal_tests/test_ds.py
@@ -119,7 +119,7 @@ class DataSourceTest(SimpleTestCase):
# Loading up the data source
ds = DataSource(source.ds)
- # Making sure the layer count is what's expected (only 1 layer in a SHP file)
+ # The layer count is what's expected (only 1 layer in a SHP file).
self.assertEqual(1, len(ds))
# Making sure GetName works
@@ -194,8 +194,9 @@ class DataSourceTest(SimpleTestCase):
for i, fid in enumerate(source.fids):
feat = layer[fid]
self.assertEqual(fid, feat.fid)
- # Maybe this should be in the test below, but we might as well test
- # the feature values here while in this loop.
+ # Maybe this should be in the test below, but we might
+ # as well test the feature values here while in this
+ # loop.
for fld_name, fld_value in source.field_values.items():
self.assertEqual(fld_value[i], feat.get(fld_name))
diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py
index cb4588450c..175ec3c7da 100644
--- a/tests/gis_tests/gdal_tests/test_geom.py
+++ b/tests/gis_tests/gdal_tests/test_geom.py
@@ -618,7 +618,8 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin):
self.assertEqual(
OGRGeometry("POINT(0 0)"),
OGRGeometry.from_gml(
- '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">'
+ '<gml:Point gml:id="p21" '
+ 'srsName="http://www.opengis.net/def/crs/EPSG/0/4326">'
' <gml:pos srsDimension="2">0 0</gml:pos>'
"</gml:Point>"
),
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index 795fdd079f..fd59b57313 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -384,11 +384,16 @@ class GDALRasterTests(SimpleTestCase):
]:
self.assertIn(line, info_lines)
for line in [
- r'Upper Left \( 511700.468, 435103.377\) \( 82d51\'46.1\d"W, 27d55\' 1.5\d"N\)',
- r'Lower Left \( 511700.468, 417703.377\) \( 82d51\'52.0\d"W, 27d45\'37.5\d"N\)',
- r'Upper Right \( 528000.468, 435103.377\) \( 82d41\'48.8\d"W, 27d54\'56.3\d"N\)',
- r'Lower Right \( 528000.468, 417703.377\) \( 82d41\'55.5\d"W, 27d45\'32.2\d"N\)',
- r'Center \( 519850.468, 426403.377\) \( 82d46\'50.6\d"W, 27d50\'16.9\d"N\)',
+ r"Upper Left \( 511700.468, 435103.377\) "
+ r'\( 82d51\'46.1\d"W, 27d55\' 1.5\d"N\)',
+ r"Lower Left \( 511700.468, 417703.377\) "
+ r'\( 82d51\'52.0\d"W, 27d45\'37.5\d"N\)',
+ r"Upper Right \( 528000.468, 435103.377\) "
+ r'\( 82d41\'48.8\d"W, 27d54\'56.3\d"N\)',
+ r"Lower Right \( 528000.468, 417703.377\) "
+ r'\( 82d41\'55.5\d"W, 27d45\'32.2\d"N\)',
+ r"Center \( 519850.468, 426403.377\) "
+ r'\( 82d46\'50.6\d"W, 27d50\'16.9\d"N\)',
]:
self.assertRegex(infos, line)
# CRS (skip the name because string depends on the GDAL/Proj versions).
diff --git a/tests/gis_tests/gdal_tests/test_srs.py b/tests/gis_tests/gdal_tests/test_srs.py
index 320d215482..8a2973cf00 100644
--- a/tests/gis_tests/gdal_tests/test_srs.py
+++ b/tests/gis_tests/gdal_tests/test_srs.py
@@ -45,7 +45,8 @@ srlist = (
),
),
TestSRS(
- 'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",DATUM["North_American_Datum_1983",'
+ 'PROJCS["NAD83 / Texas South Central",'
+ 'GEOGCS["NAD83",DATUM["North_American_Datum_1983",'
'SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],'
'AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
'UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],'
@@ -78,13 +79,18 @@ srlist = (
TestSRS(
'PROJCS["NAD83 / Texas South Central (ftUS)",'
'GEOGCS["NAD83",DATUM["North_American_Datum_1983",'
- 'SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],'
+ 'SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],'
+ 'AUTHORITY["EPSG","6269"]],'
'PRIMEM["Greenwich",0],'
'UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic_2SP"],'
- 'PARAMETER["false_easting",1968500],PARAMETER["false_northing",13123333.3333333],'
- 'PARAMETER["central_meridian",-99],PARAMETER["standard_parallel_1",28.3833333333333],'
- 'PARAMETER["standard_parallel_2",30.2833333333333],PARAMETER["latitude_of_origin",27.8333333333333],'
- 'UNIT["US survey foot",0.304800609601219],AXIS["Easting",EAST],AXIS["Northing",NORTH]]',
+ 'PARAMETER["false_easting",1968500],'
+ 'PARAMETER["false_northing",13123333.3333333],'
+ 'PARAMETER["central_meridian",-99],'
+ 'PARAMETER["standard_parallel_1",28.3833333333333],'
+ 'PARAMETER["standard_parallel_2",30.2833333333333],'
+ 'PARAMETER["latitude_of_origin",27.8333333333333],'
+ 'UNIT["US survey foot",0.304800609601219],AXIS["Easting",EAST],'
+ 'AXIS["Northing",NORTH]]',
epsg=None,
projected=True,
geographic=False,
@@ -122,7 +128,8 @@ well_known = (
TestSRS(
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,'
'AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],'
- 'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,'
+ 'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
+ 'UNIT["degree",0.01745329251994328,'
'AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]',
wk="WGS84",
name="WGS 84",
@@ -324,13 +331,16 @@ class SpatialRefTest(SimpleTestCase):
wkt = (
'PROJCS["DHDN / Soldner 39 Langschoß",'
'GEOGCS["DHDN",DATUM["Deutsches_Hauptdreiecksnetz",'
- 'SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],AUTHORITY["EPSG","6314"]],'
+ 'SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],'
+ 'AUTHORITY["EPSG","6314"]],'
'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
'UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],'
'AUTHORITY["EPSG","4314"]],PROJECTION["Cassini_Soldner"],'
- 'PARAMETER["latitude_of_origin",50.66738711],PARAMETER["central_meridian",6.28935703],'
+ 'PARAMETER["latitude_of_origin",50.66738711],'
+ 'PARAMETER["central_meridian",6.28935703],'
'PARAMETER["false_easting",0],PARAMETER["false_northing",0],'
- 'UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",NORTH],AXIS["Y",EAST],AUTHORITY["mj10777.de","187939"]]'
+ 'UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",NORTH],AXIS["Y",EAST],'
+ 'AUTHORITY["mj10777.de","187939"]]'
)
srs = SpatialReference(wkt)
srs_list = [srs, srs.clone()]
diff --git a/tests/gis_tests/geoadmin_deprecated/tests.py b/tests/gis_tests/geoadmin_deprecated/tests.py
index a2049827a1..dd3e3af069 100644
--- a/tests/gis_tests/geoadmin_deprecated/tests.py
+++ b/tests/gis_tests/geoadmin_deprecated/tests.py
@@ -16,15 +16,18 @@ class GeoAdminTest(SimpleTestCase):
self.assertTrue(any(geoadmin.openlayers_url in js for js in admin_js))
def test_olmap_OSM_rendering(self):
- delete_all_btn = """<a href="javascript:geodjango_point.clearFeatures()">Delete all Features</a>"""
-
+ delete_all_btn = (
+ '<a href="javascript:geodjango_point.clearFeatures()">Delete all Features'
+ "</a>"
+ )
original_geoadmin = site._registry[City]
params = original_geoadmin.get_map_widget(City._meta.get_field("point")).params
result = original_geoadmin.get_map_widget(
City._meta.get_field("point")
)().render("point", Point(-79.460734, 40.18476), params)
self.assertIn(
- """geodjango_point.layers.base = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");""",
+ "geodjango_point.layers.base = "
+ 'new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");',
result,
)
@@ -50,8 +53,9 @@ class GeoAdminTest(SimpleTestCase):
"point", Point(-79.460734, 40.18476)
)
self.assertIn(
- """geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", """
- """"http://vmap0.tiles.osgeo.org/wms/vmap0", {layers: 'basic', format: 'image/jpeg'});""",
+ 'geodjango_point.layers.base = new OpenLayers.Layer.WMS("OpenLayers WMS", '
+ '"http://vmap0.tiles.osgeo.org/wms/vmap0", '
+ "{layers: 'basic', format: 'image/jpeg'});",
result,
)
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index 076e51b7a2..b632d2cf61 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -36,12 +36,14 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
'{"name":"EPSG:4326"}},"coordinates":[-95.363151,29.763374]}'
)
victoria_json = json.loads(
- '{"type":"Point","bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],'
+ '{"type":"Point",'
+ '"bbox":[-123.30519600,48.46261100,-123.30519600,48.46261100],'
'"coordinates":[-123.305196,48.462611]}'
)
chicago_json = json.loads(
'{"type":"Point","crs":{"type":"name","properties":{"name":"EPSG:4326"}},'
- '"bbox":[-87.65018,41.85039,-87.65018,41.85039],"coordinates":[-87.65018,41.85039]}'
+ '"bbox":[-87.65018,41.85039,-87.65018,41.85039],'
+ '"coordinates":[-87.65018,41.85039]}'
)
if "crs" in connection.features.unsupported_geojson_options:
del houston_json["crs"]
@@ -131,8 +133,10 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
if connection.ops.oracle:
# No precision parameter for Oracle :-/
gml_regex = re.compile(
- r'^<gml:Point srsName="EPSG:4326" xmlns:gml="http://www.opengis.net/gml">'
- r'<gml:coordinates decimal="\." cs="," ts=" ">-104.60925\d+,38.25500\d+ '
+ r'^<gml:Point srsName="EPSG:4326" '
+ r'xmlns:gml="http://www.opengis.net/gml">'
+ r'<gml:coordinates decimal="\." cs="," ts=" ">'
+ r"-104.60925\d+,38.25500\d+ "
r"</gml:coordinates></gml:Point>"
)
else:
@@ -588,7 +592,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
# to pass into GEOS `equals_exact`.
tol = 0.000000001
- # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.1)) FROM "geoapp_country"
+ # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.1))
+ # FROM "geoapp_country"
# WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr("MULTIPOLYGON(((12.4 44,12.5 44,12.5 43.9,12.4 43.9,12.4 44)))")
self.assertTrue(
@@ -600,7 +605,8 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
)
)
- # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.05, 0.23)) FROM "geoapp_country"
+ # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.05, 0.23))
+ # FROM "geoapp_country"
# WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr(
"MULTIPOLYGON(((12.4 43.93,12.45 43.93,12.5 43.93,12.45 43.93,12.4 43.93)))"
@@ -614,10 +620,12 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
)
)
- # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.5, 0.17, 0.05, 0.23)) FROM "geoapp_country"
+ # SELECT AsText(ST_SnapToGrid("geoapp_country"."mpoly", 0.5, 0.17, 0.05, 0.23))
+ # FROM "geoapp_country"
# WHERE "geoapp_country"."name" = 'San Marino';
ref = fromstr(
- "MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,12.45 43.87,12.4 43.87)))"
+ "MULTIPOLYGON(((12.4 43.87,12.45 43.87,12.45 44.1,12.5 44.1,12.5 43.87,"
+ "12.45 43.87,12.4 43.87)))"
)
self.assertTrue(
ref.equals_exact(
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 33d209bcdb..6acf6e150b 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -301,8 +301,8 @@ class GeoLookupTest(TestCase):
ks = State.objects.get(poly__contains=lawrence.point)
self.assertEqual("Kansas", ks.name)
- # Pueblo and Oklahoma City (even though OK City is within the bounding box of Texas)
- # are not contained in Texas or New Zealand.
+ # Pueblo and Oklahoma City (even though OK City is within the bounding
+ # box of Texas) are not contained in Texas or New Zealand.
self.assertEqual(
len(Country.objects.filter(mpoly__contains=pueblo.point)), 0
) # Query w/GEOSGeometry object
@@ -597,8 +597,10 @@ class GeoQuerySetTest(TestCase):
Testing the `Extent` aggregate.
"""
# Reference query:
- # `SELECT ST_extent(point) FROM geoapp_city WHERE (name='Houston' or name='Dallas');`
- # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984 32.7820587158203)
+ # SELECT ST_extent(point)
+ # FROM geoapp_city
+ # WHERE (name='Houston' or name='Dallas');`
+ # => BOX(-96.8016128540039 29.7633724212646,-95.3631439208984 32.7820587158203)
expected = (
-96.8016128540039,
29.7633724212646,
diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py
index 819b86545f..ae12d26706 100644
--- a/tests/gis_tests/geogapp/tests.py
+++ b/tests/gis_tests/geogapp/tests.py
@@ -39,7 +39,10 @@ class GeographyTest(TestCase):
self.assertEqual(["Dallas", "Houston", "Oklahoma City"], cities)
def test04_invalid_operators_functions(self):
- "Ensuring exceptions are raised for operators & functions invalid on geography fields."
+ """
+ Exceptions are raised for operators & functions invalid on geography
+ fields.
+ """
if not connection.ops.postgis:
self.skipTest("This is a PostGIS-specific test.")
# Only a subset of the geometry functions & operator are available
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index d37d826d39..4754f17c9b 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -807,7 +807,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
buf_ring = buf[j]
self.assertEqual(len(exp_ring), len(buf_ring))
for k in range(len(exp_ring)):
- # 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_ring[k][0], buf_ring[k][0], 9)
self.assertAlmostEqual(exp_ring[k][1], buf_ring[k][1], 9)
@@ -1496,7 +1497,8 @@ class GEOSTest(SimpleTestCase, TestDataMixin):
self.assertEqual(
GEOSGeometry("POINT(0 0)"),
GEOSGeometry.from_gml(
- '<gml:Point gml:id="p21" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">'
+ '<gml:Point gml:id="p21" '
+ 'srsName="http://www.opengis.net/def/crs/EPSG/0/4326">'
' <gml:pos srsDimension="2">0 0</gml:pos>'
"</gml:Point>"
),
diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py
index 952124db8c..d9b3cf985f 100644
--- a/tests/gis_tests/inspectapp/tests.py
+++ b/tests/gis_tests/inspectapp/tests.py
@@ -132,7 +132,8 @@ class OGRInspectTest(SimpleTestCase):
self.assertTrue(
model_def.startswith(
- "# This is an auto-generated Django model module created by ogrinspect.\n"
+ "# This is an auto-generated Django model module created by "
+ "ogrinspect.\n"
"from django.contrib.gis.db import models\n"
"\n"
"\n"
@@ -140,7 +141,8 @@ class OGRInspectTest(SimpleTestCase):
)
)
- # The ordering of model fields might vary depending on several factors (version of GDAL, etc.)
+ # The ordering of model fields might vary depending on several factors
+ # (version of GDAL, etc.).
if connection.vendor == "sqlite":
# SpatiaLite introspection is somewhat lacking (#29461).
self.assertIn(" f_decimal = models.CharField(max_length=0)", model_def)
diff --git a/tests/gis_tests/layermap/models.py b/tests/gis_tests/layermap/models.py
index 953332539a..02a8914f02 100644
--- a/tests/gis_tests/layermap/models.py
+++ b/tests/gis_tests/layermap/models.py
@@ -92,7 +92,8 @@ class DoesNotAllowNulls(models.Model):
# Mapping dictionaries for the models above.
co_mapping = {
"name": "Name",
- # ForeignKey's use another mapping dictionary for the _related_ Model (State in this case).
+ # ForeignKey's use another mapping dictionary for the _related_ Model
+ # (State in this case).
"state": {"name": "State"},
"mpoly": "MULTIPOLYGON", # Will convert POLYGON features into MULTIPOLYGONS.
}
diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py
index a7aafcc60c..89e430d2c9 100644
--- a/tests/gis_tests/layermap/tests.py
+++ b/tests/gis_tests/layermap/tests.py
@@ -151,7 +151,10 @@ class LayerMapTest(TestCase):
self.assertEqual(n, qs.count())
def test_layermap_unique_multigeometry_fk(self):
- "Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings."
+ """
+ The `unique`, and `transform`, geometry collection conversion, and
+ ForeignKey mappings.
+ """
# All the following should work.
# Telling LayerMapping that we want no transformations performed on the data.
diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py
index 48f9c12b69..d93fe3b76b 100644
--- a/tests/gis_tests/relatedapp/tests.py
+++ b/tests/gis_tests/relatedapp/tests.py
@@ -104,7 +104,9 @@ class RelatedGeoModelTest(TestCase):
self.assertEqual({p.ewkt for p in ref_u1}, {p.ewkt for p in u3})
def test05_select_related_fk_to_subclass(self):
- "Testing that calling select_related on a query over a model with an FK to a model subclass works"
+ """
+ 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())
@@ -282,9 +284,13 @@ class RelatedGeoModelTest(TestCase):
Testing the `Collect` aggregate.
"""
# Reference query:
- # SELECT AsText(ST_Collect("relatedapp_location"."point")) FROM "relatedapp_city" LEFT OUTER JOIN
- # "relatedapp_location" ON ("relatedapp_city"."location_id" = "relatedapp_location"."id")
- # WHERE "relatedapp_city"."state" = 'TX';
+ # SELECT AsText(ST_Collect("relatedapp_location"."point"))
+ # FROM "relatedapp_city"
+ # LEFT OUTER JOIN
+ # "relatedapp_location" ON (
+ # "relatedapp_city"."location_id" = "relatedapp_location"."id"
+ # )
+ # WHERE "relatedapp_city"."state" = 'TX';
ref_geom = GEOSGeometry(
"MULTIPOINT(-97.516111 33.058333,-96.801611 32.782057,"
"-95.363151 29.763374,-96.801611 32.782057)"
@@ -299,7 +305,9 @@ class RelatedGeoModelTest(TestCase):
self.assertTrue(ref_geom.equals(coll))
def test15_invalid_select_related(self):
- "Testing doing select_related on the related name manager of a unique FK. See #13934."
+ """
+ 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
diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py
index 949ad46a41..cef88d7115 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -96,7 +96,8 @@ class GeometryFieldTest(SimpleTestCase):
"MULTI POLYGON(((0 0, 0 1, 1 1, 1 0, 0 0)))",
"BLAH(0 0, 1 1)",
'{"type": "FeatureCollection", "features": ['
- '{"geometry": {"type": "Point", "coordinates": [508375, 148905]}, "type": "Feature"}]}',
+ '{"geometry": {"type": "Point", "coordinates": [508375, 148905]}, '
+ '"type": "Feature"}]}',
]
fld = forms.GeometryField()
# to_python returns the same GEOSGeometry for a WKT
diff --git a/tests/gis_tests/test_spatialrefsys.py b/tests/gis_tests/test_spatialrefsys.py
index e23ea2ba2a..7151e8d3d6 100644
--- a/tests/gis_tests/test_spatialrefsys.py
+++ b/tests/gis_tests/test_spatialrefsys.py
@@ -12,7 +12,10 @@ test_srs = (
# Only the beginning, because there are differences depending on installed libs
"srtext": 'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84"',
# +ellps=WGS84 has been removed in the 4326 proj string in proj-4.8
- "proj_re": r"\+proj=longlat (\+ellps=WGS84 )?(\+datum=WGS84 |\+towgs84=0,0,0,0,0,0,0 )\+no_defs ?",
+ "proj_re": (
+ r"\+proj=longlat (\+ellps=WGS84 )?(\+datum=WGS84 |\+towgs84=0,0,0,0,0,0,0 )"
+ r"\+no_defs ?"
+ ),
"spheroid": "WGS 84",
"name": "WGS 84",
"geographic": True,
@@ -46,9 +49,12 @@ test_srs = (
'PROJCS["NAD83 / Texas South Central",GEOGCS["NAD83",'
'DATUM["North_American_Datum_1983",SPHEROID["GRS 1980"'
),
- "proj_re": r"\+proj=lcc (\+lat_1=30.28333333333333? |\+lat_2=28.38333333333333? |\+lat_0=27.83333333333333? |"
- r"\+lon_0=-99 ){4}\+x_0=600000 \+y_0=4000000 (\+ellps=GRS80 )?"
- r"(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0 )?\+units=m \+no_defs ?",
+ "proj_re": (
+ r"\+proj=lcc (\+lat_1=30.28333333333333? |\+lat_2=28.38333333333333? "
+ r"|\+lat_0=27.83333333333333? |"
+ r"\+lon_0=-99 ){4}\+x_0=600000 \+y_0=4000000 (\+ellps=GRS80 )?"
+ r"(\+datum=NAD83 |\+towgs84=0,0,0,0,0,0,0 )?\+units=m \+no_defs ?"
+ ),
"spheroid": "GRS 1980",
"name": "NAD83 / Texas South Central",
"geographic": False,