Skip to content

Commit fa4f08b

Browse files
committed
Use ignore_cleanup_errors on the DstRect-cap test tempdirs
The new test cases on this PR write a source TIFF inside a TemporaryDirectory before invoking read_vrt. On Windows the read path can leave a file handle open just past the context exit, so shutil.rmtree raises WinError 32 (same shape as #1748). Linux closes in time and never trips. ignore_cleanup_errors=True keeps the cleanup best-effort. The assertions still run inside the context so a real failure still fails the test; only the tempdir teardown is now tolerant.
1 parent c0f9ab8 commit fa4f08b

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

xrspatial/geotiff/tests/test_vrt_dstrect_resample_cap_1737.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def _write_vrt(td: str, *, dst_x_size: int, dst_y_size: int,
5656
def test_huge_dstrect_rejected_before_intermediate_allocation():
5757
"""A DstRect that would force a multi-billion-pixel resample intermediate
5858
must raise ``ValueError`` before ``_resample_nearest`` allocates."""
59-
with tempfile.TemporaryDirectory() as td:
59+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
6060
_write_source(td)
6161
# 50000 x 50000 = 2.5 billion pixels of intermediate; the output
6262
# buffer is only 100 x 100. With the cap in place this should
@@ -68,7 +68,7 @@ def test_huge_dstrect_rejected_before_intermediate_allocation():
6868

6969
def test_huge_dstrect_y_axis_rejected():
7070
"""Asymmetric blow-up: only one axis is huge. Still rejected."""
71-
with tempfile.TemporaryDirectory() as td:
71+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
7272
_write_source(td)
7373
vrt_path = _write_vrt(
7474
td, dst_x_size=10, dst_y_size=10_000_000_000)
@@ -78,7 +78,7 @@ def test_huge_dstrect_y_axis_rejected():
7878

7979
def test_legitimate_upsample_still_works():
8080
"""A legitimate upsample stays under the cap and must succeed."""
81-
with tempfile.TemporaryDirectory() as td:
81+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
8282
_write_source(td)
8383
# 100 x 100 destination, matches the VRT extent.
8484
vrt_path = _write_vrt(td, dst_x_size=100, dst_y_size=100)
@@ -95,7 +95,7 @@ def test_max_pixels_kwarg_raises_cap():
9595
bites on the resample intermediate, not on the ``_check_dimensions``
9696
pre-allocation guard.
9797
"""
98-
with tempfile.TemporaryDirectory() as td:
98+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
9999
_write_source(td)
100100
# 2000x2000 = 4e6 intermediate pixels. Output buffer is 10x10=100
101101
# pixels, far below both caps below. Upsample 10x10 -> 2000x2000
@@ -114,7 +114,7 @@ def test_dstrect_at_cap_succeeds():
114114
"""Exactly at ``max_pixels`` is accepted; the cap is inclusive.
115115
Together with :func:`test_max_pixels_kwarg_raises_cap`, this pins
116116
down both sides of the override boundary."""
117-
with tempfile.TemporaryDirectory() as td:
117+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
118118
_write_source(td)
119119
# Upsample 10x10 -> 100x100 so ``needs_resample`` is true. The
120120
# VRT raster is 10x10 so the output buffer stays at 100 pixels,
@@ -135,7 +135,7 @@ def test_negative_dstrect_rejected():
135135
rather than be silently skipped by the overlap check. The error
136136
message must call out the malformed negative size, not the pixel
137137
budget."""
138-
with tempfile.TemporaryDirectory() as td:
138+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
139139
_write_source(td)
140140
vrt_path = _write_vrt(td, dst_x_size=-5, dst_y_size=100)
141141
with pytest.raises(ValueError, match="negative size"):
@@ -144,7 +144,7 @@ def test_negative_dstrect_rejected():
144144

145145
def test_negative_dstrect_y_size_rejected():
146146
"""Negative ``ySize`` is also rejected with the same tailored error."""
147-
with tempfile.TemporaryDirectory() as td:
147+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
148148
_write_source(td)
149149
vrt_path = _write_vrt(td, dst_x_size=100, dst_y_size=-5)
150150
with pytest.raises(ValueError, match="negative size"):

0 commit comments

Comments
 (0)