@@ -455,3 +455,33 @@ def test_gdaladdo_partial_refresh_from_source_timestamp_gti(gdaladdo_path, tmp_p
455
455
ovr_data_refreshed [idx ] = ovr_data_ori [idx ]
456
456
assert ovr_data_refreshed == ovr_data_ori
457
457
ds = None
458
+
459
+
460
+ ###############################################################################
461
+ #
462
+
463
+
464
+ def test_gdaladdo_illegal_factor (gdaladdo_path , tmp_path ):
465
+
466
+ shutil .copyfile ("../gcore/data/byte.tif" , f"{ tmp_path } /byte.tif" )
467
+
468
+ _ , err = gdaltest .runexternal_out_and_err (
469
+ f"{ gdaladdo_path } -r average { tmp_path } /byte.tif invalid"
470
+ )
471
+ assert "Value 'invalid' is not a positive integer subsampling factor" in err
472
+ with gdal .Open (f"{ tmp_path } /byte.tif" ) as ds :
473
+ assert ds .GetRasterBand (1 ).GetOverviewCount () == 0
474
+
475
+ _ , err = gdaltest .runexternal_out_and_err (
476
+ f"{ gdaladdo_path } -r average { tmp_path } /byte.tif 0"
477
+ )
478
+ assert "Value '0' is not a positive integer subsampling factor" in err
479
+ with gdal .Open (f"{ tmp_path } /byte.tif" ) as ds :
480
+ assert ds .GetRasterBand (1 ).GetOverviewCount () == 0
481
+
482
+ _ , err = gdaltest .runexternal_out_and_err (
483
+ f"{ gdaladdo_path } -r average { tmp_path } /byte.tif -1"
484
+ )
485
+ assert "Value '-1' is not a positive integer subsampling factor" in err
486
+ with gdal .Open (f"{ tmp_path } /byte.tif" ) as ds :
487
+ assert ds .GetRasterBand (1 ).GetOverviewCount () == 0
0 commit comments