From d144c34c194ff4f73b48a4a643d35b522d9f0688 Mon Sep 17 00:00:00 2001 From: Brendan Collins Date: Mon, 25 May 2026 07:42:59 -0700 Subject: [PATCH] Accept VRTUnsupportedError in resample-alg rejection test The centralised VRT capability validator (#2329, merged via #2376) raises VRTUnsupportedError at parse time before the legacy NotImplementedError site at the resample call. The parametrised test_unsupported_resample_alg_raises was still asserting only NotImplementedError, so it started failing on main once both PRs landed. Broaden the expected exception type to (NotImplementedError, ValueError) so the test passes whichever rejection path fires first. VRTUnsupportedError subclasses ValueError, and the algorithm-name assertion still locks the actionable-message contract. Matches the dual-type rejection already documented in the sister test_unsupported_resample_alg_open_geotiff. --- .../geotiff/tests/test_vrt_unsupported_2370.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/xrspatial/geotiff/tests/test_vrt_unsupported_2370.py b/xrspatial/geotiff/tests/test_vrt_unsupported_2370.py index 93d9f922..21318653 100644 --- a/xrspatial/geotiff/tests/test_vrt_unsupported_2370.py +++ b/xrspatial/geotiff/tests/test_vrt_unsupported_2370.py @@ -433,11 +433,14 @@ def test_complex_mask_source_raises(tmp_path): @pytest.mark.parametrize('alg', ['Bilinear', 'Cubic', 'Lanczos', 'Average', 'Mode']) def test_unsupported_resample_alg_raises(tmp_path, alg): - """Already enforced by issue #1751: a ```` value - outside the implemented nearest subset, paired with size-changing - SrcRect/DstRect rects, raises ``NotImplementedError`` with the - algorithm name in the message. Lock that contract in here so the - rejection survives any future refactor. + """A ```` value outside the implemented nearest subset, + paired with size-changing SrcRect/DstRect rects, is rejected with + the algorithm name in the message. The legacy resample-site check + (#1751) raises ``NotImplementedError``; the centralised validator + (#2329) raises ``VRTUnsupportedError`` (a ``ValueError`` subclass) + at parse time. Either is a valid rejection so long as the message + names the offending algorithm -- matches the dual-type contract in + ``test_unsupported_resample_alg_open_geotiff``. """ src_path = _write_src_tif(tmp_path, name=f'res_{alg.lower()}') inner = f'{alg}' @@ -453,7 +456,7 @@ def test_unsupported_resample_alg_raises(tmp_path, alg): xml = _vrt_xml(width=2, height=2, body=body) vrt_path = _write_vrt(tmp_path, xml, f'resample_{alg.lower()}') - with pytest.raises(NotImplementedError) as excinfo: + with pytest.raises((NotImplementedError, ValueError)) as excinfo: read_vrt(vrt_path) msg = str(excinfo.value) assert alg in msg, f"error must name the rejected algorithm: {msg!r}"