Refs #33577 -- Used addCleanup() to remove .aux file in GDALBandTests.

Follow up to 970f5bf503.
This commit is contained in:
Mariusz Felisiak 2022-03-24 09:13:24 +01:00 committed by GitHub
parent bb61f0186d
commit 1b695fbbc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -801,19 +801,20 @@ class GDALBandTests(SimpleTestCase):
rs = band = None rs = band = None
self.assertTrue(os.path.isfile(pam_file)) 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): def test_read_mode_error(self):
# Open raster in read mode # Open raster in read mode
rs = GDALRaster(self.rs_path, write=False) rs = GDALRaster(self.rs_path, write=False)
band = rs.bands[0] band = rs.bands[0]
self.addCleanup(self._remove_aux_file)
# Setting attributes in write mode raises exception in the _flush method # Setting attributes in write mode raises exception in the _flush method
try: with self.assertRaises(GDALException):
with self.assertRaises(GDALException): setattr(band, "nodata_value", 10)
setattr(band, "nodata_value", 10)
finally:
pam_file = self.rs_path + ".aux.xml"
if os.path.isfile(pam_file):
os.remove(pam_file)
def test_band_data_setters(self): def test_band_data_setters(self):
# Create in-memory raster and get band # Create in-memory raster and get band