summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-06-30 06:03:08 +0200
committerGitHub <noreply@github.com>2023-06-30 06:03:08 +0200
commit953f29f700a60fc09b08b2c2270c12c447490c6a (patch)
tree090ff24f74561cb91ae353054cecc06fc835d1eb /tests
parenta40b0103bccb8216c944188d329d8ea5eceb7e92 (diff)
Fixed #34572 -- Added support for GDAL 3.7.
Co-authored-by: Michael Howitz <mh@gocept.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index c662366bef..67108cbb32 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -6,7 +6,7 @@ import zipfile
from pathlib import Path
from unittest import mock
-from django.contrib.gis.gdal import GDALRaster, SpatialReference
+from django.contrib.gis.gdal import GDAL_VERSION, 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
@@ -415,9 +415,19 @@ class GDALRasterTests(SimpleTestCase):
# Check physically if compression worked.
self.assertLess(os.path.getsize(compressed.name), os.path.getsize(self.rs.name))
# Create file-based raster with options from scratch.
+ papsz_options = {
+ "compress": "packbits",
+ "blockxsize": 23,
+ "blockysize": 23,
+ }
+ if GDAL_VERSION < (3, 7):
+ datatype = 1
+ papsz_options["pixeltype"] = "signedbyte"
+ else:
+ datatype = 14
compressed = GDALRaster(
{
- "datatype": 1,
+ "datatype": datatype,
"driver": "tif",
"name": rstfile.name,
"width": 40,
@@ -432,12 +442,7 @@ class GDALRasterTests(SimpleTestCase):
"nodata_value": 255,
}
],
- "papsz_options": {
- "compress": "packbits",
- "pixeltype": "signedbyte",
- "blockxsize": 23,
- "blockysize": 23,
- },
+ "papsz_options": papsz_options,
}
)
# Check if options used on creation are stored in metadata.
@@ -448,9 +453,12 @@ class GDALRasterTests(SimpleTestCase):
compressed.metadata["IMAGE_STRUCTURE"]["COMPRESSION"],
"PACKBITS",
)
- self.assertEqual(
- compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"], "SIGNEDBYTE"
- )
+ self.assertEqual(compressed.bands[0].datatype(), datatype)
+ if GDAL_VERSION < (3, 7):
+ self.assertEqual(
+ compressed.bands[0].metadata["IMAGE_STRUCTURE"]["PIXELTYPE"],
+ "SIGNEDBYTE",
+ )
self.assertIn("Block=40x23", compressed.info)
def test_raster_warp(self):