diff options
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) |
