diff options
| author | Daniel Wiesmann <daniel.wiesmann@gmail.com> | 2016-03-28 19:12:10 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2016-03-29 08:06:31 -0400 |
| commit | f1db8c36e9178dcfa14a6bfcad48122a3a5ceea3 (patch) | |
| tree | 1721e8d0edd43d63b18787fd583a78bd94334e2b /tests | |
| parent | a7c813ba045044ec23bb656ef9a23a0e38e36514 (diff) | |
Fixed #26415 -- Allowed deleting nodata value on GDALBands.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/gdal_tests/test_raster.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py index 8391887f6c..d08071342c 100644 --- a/tests/gis_tests/gdal_tests/test_raster.py +++ b/tests/gis_tests/gdal_tests/test_raster.py @@ -48,6 +48,7 @@ import unittest from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.shortcuts import numpy +from django.test import SimpleTestCase from django.utils import six from django.utils._os import upath @@ -302,7 +303,7 @@ class GDALRasterTests(unittest.TestCase): @unittest.skipUnless(HAS_GDAL, "GDAL is required") -class GDALBandTests(unittest.TestCase): +class GDALBandTests(SimpleTestCase): def setUp(self): self.rs_path = os.path.join(os.path.dirname(upath(__file__)), '../data/rasters/raster.tif') @@ -467,3 +468,18 @@ class GDALBandTests(unittest.TestCase): 'bands': [{'data': [0], 'nodata_value': 0}], }) self.assertEqual(rsmem.bands[0].statistics(), (None, None, None, None)) + + def test_band_delete_nodata(self): + rsmem = GDALRaster({ + 'srid': 4326, + 'width': 1, + 'height': 1, + 'bands': [{'data': [0], 'nodata_value': 1}], + }) + if GDAL_VERSION < (2, 1): + msg = 'GDAL >= 2.1 required to delete nodata values.' + with self.assertRaisesMessage(ValueError, msg): + rsmem.bands[0].nodata_value = None + else: + rsmem.bands[0].nodata_value = None + self.assertIsNone(rsmem.bands[0].nodata_value) |
