diff options
author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-03-24 09:13:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 09:13:24 +0100 |
commit | 1b695fbbc203c163bf7b8d78f6313a6c506fb938 (patch) | |
tree | aded10ba9209d18d7dc18da03aa0697e5a98bcf5 /tests/gis_tests | |
parent | bb61f0186d5c490caa44f3e3672d81e14414d33c (diff) | |
download | django-1b695fbbc203c163bf7b8d78f6313a6c506fb938.tar.gz |
Refs #33577 -- Used addCleanup() to remove .aux file in GDALBandTests.
Follow up to 970f5bf5035d8c99b0ff883f984b60cf531dddbe.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r-- | tests/gis_tests/gdal_tests/test_raster.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py index 5185df2667..21f8fd27ac 100644 --- a/tests/gis_tests/gdal_tests/test_raster.py +++ b/tests/gis_tests/gdal_tests/test_raster.py @@ -801,19 +801,20 @@ class GDALBandTests(SimpleTestCase): 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 |