summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorHeath Henley <heath.henley@farsounder.com>2023-03-02 13:14:24 -0500
committerGitHub <noreply@github.com>2023-03-02 19:14:24 +0100
commit56e5ea805ba0ddfbdd74b00714bf893af1d5a976 (patch)
treea0dac93c9c3a48db6899628b9af507f042b9188f /tests/gis_tests
parent4cb55733527d39ebf58c1987f72a19b7c2e0bac6 (diff)
downloaddjango-56e5ea805ba0ddfbdd74b00714bf893af1d5a976.tar.gz
Fixed #34374 -- Fixed GIS tests on Windows.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py15
-rw-r--r--tests/gis_tests/geoapp/tests.py4
2 files changed, 10 insertions, 9 deletions
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index cbe7d6b369..c662366bef 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -10,6 +10,7 @@ from django.contrib.gis.gdal import GDALRaster, SpatialReference
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.raster.band import GDALBand
from django.contrib.gis.shortcuts import numpy
+from django.core.files.temp import NamedTemporaryFile
from django.test import SimpleTestCase
from ..data.rasters.textrasters import JSON_RASTER
@@ -148,7 +149,7 @@ class GDALRasterTests(SimpleTestCase):
def test_file_based_raster_creation(self):
# Prepare tempfile
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
# Create file-based raster from scratch
GDALRaster(
@@ -264,7 +265,7 @@ class GDALRasterTests(SimpleTestCase):
self.assertIsNone(self.rs.vsi_buffer)
def test_vsi_vsizip_filesystem(self):
- rst_zipfile = tempfile.NamedTemporaryFile(suffix=".zip")
+ rst_zipfile = NamedTemporaryFile(suffix=".zip")
with zipfile.ZipFile(rst_zipfile, mode="w") as zf:
zf.write(self.rs_path, "raster.tif")
rst_path = "/vsizip/" + os.path.join(rst_zipfile.name, "raster.tif")
@@ -406,7 +407,7 @@ class GDALRasterTests(SimpleTestCase):
self.assertIn("NAD83 / Florida GDL Albers", infos)
def test_compressed_file_based_raster_creation(self):
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
# Make a compressed copy of an existing raster.
compressed = self.rs.warp(
{"papsz_options": {"compress": "packbits"}, "name": rstfile.name}
@@ -554,7 +555,7 @@ class GDALRasterTests(SimpleTestCase):
self.assertEqual(result, [23] * 16)
def test_raster_clone(self):
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
tests = [
("MEM", "", 23), # In memory raster.
("tif", rstfile.name, 99), # In file based raster.
@@ -600,7 +601,7 @@ class GDALRasterTests(SimpleTestCase):
for srs in tests:
with self.subTest(srs=srs):
# Prepare tempfile and nodata value.
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
ndv = 99
# Create in file based raster.
source = GDALRaster(
@@ -701,7 +702,7 @@ class GDALRasterTests(SimpleTestCase):
def test_raster_transform_clone(self):
with mock.patch.object(GDALRaster, "clone") as mocked_clone:
# Create in file based raster.
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
source = GDALRaster(
{
"datatype": 1,
@@ -729,7 +730,7 @@ class GDALRasterTests(SimpleTestCase):
def test_raster_transform_clone_name(self):
# Create in file based raster.
- rstfile = tempfile.NamedTemporaryFile(suffix=".tif")
+ rstfile = NamedTemporaryFile(suffix=".tif")
source = GDALRaster(
{
"datatype": 1,
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 3cecd70094..e7971c179b 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -1,4 +1,3 @@
-import tempfile
from io import StringIO
from django.contrib.gis import gdal
@@ -15,6 +14,7 @@ from django.contrib.gis.geos import (
Polygon,
fromstr,
)
+from django.core.files.temp import NamedTemporaryFile
from django.core.management import call_command
from django.db import DatabaseError, NotSupportedError, connection
from django.db.models import F, OuterRef, Subquery
@@ -232,7 +232,7 @@ class GeoModelTest(TestCase):
self.assertIn('"point": "%s"' % houston.point.ewkt, result)
# Reload now dumped data
- with tempfile.NamedTemporaryFile(mode="w", suffix=".json") as tmp:
+ with NamedTemporaryFile(mode="w", suffix=".json") as tmp:
tmp.write(result)
tmp.seek(0)
call_command("loaddata", tmp.name, verbosity=0)