Skip to content

Commit

Permalink
Refs #33577 -- Used addCleanup() to remove .aux file in GDALBandTests.
Browse files Browse the repository at this point in the history
Follow up to 970f5bf.
  • Loading branch information
felixxm committed Mar 24, 2022
1 parent bb61f01 commit 1b695fb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/gis_tests/gdal_tests/test_raster.py
Expand Up @@ -801,19 +801,20 @@ def test_band_statistics(self):
rs = band = None
self.assertTrue(os.path.isfile(pam_file))

def _remove_aux_file(self):
pam_file = self.rs_path + ".aux.xml"
if os.path.isfile(pam_file):
os.remove(pam_file)

def test_read_mode_error(self):
# Open raster in read mode
rs = GDALRaster(self.rs_path, write=False)
band = rs.bands[0]
self.addCleanup(self._remove_aux_file)

# Setting attributes in write mode raises exception in the _flush method
try:
with self.assertRaises(GDALException):
setattr(band, "nodata_value", 10)
finally:
pam_file = self.rs_path + ".aux.xml"
if os.path.isfile(pam_file):
os.remove(pam_file)
with self.assertRaises(GDALException):
setattr(band, "nodata_value", 10)

def test_band_data_setters(self):
# Create in-memory raster and get band
Expand Down

0 comments on commit 1b695fb

Please sign in to comment.