geotiff: fix test_writer_returns_are_not_none on Windows (#1938)#1960
Merged
Conversation
The post-merge test added in #1938 used ``tempfile.TemporaryDirectory`` for its setup. ``write_vrt`` reads each source through the module-level ``_MmapCache`` in ``_reader.py`` (kept around so repeated reads of the same file are cheap), so the file handle and mmap of ``src.tif`` stay open past ``_FileSource.close()``. On Windows that cached handle blocks ``os.unlink`` with ``WinError 32`` and the synchronous tempdir teardown fails before the test can return, breaking pytest on every Windows job. Switch the test to the ``tmp_path`` fixture used by the other seven tests in this file. ``tmp_path`` defers cleanup to pytest's session-end sweep, which tolerates the still-open handle. The library behaviour is intentional and unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI on
mainhas been failing on every Windows job since #1942 merged. The post-merge testtest_writer_returns_are_not_noneinxrspatial/geotiff/tests/test_writer_return_path_1938.pyusedtempfile.TemporaryDirectory()for its scratch space.write_vrtreads each source through the module-level_MmapCachein_reader.py, which keeps the file handle and mmap ofsrc.tifopen after_FileSource.close()so repeated reads of the same file stay cheap. On Windows that cached handle blocksos.unlink(WinError 32), and the synchronous tempdir teardown raises before the test can return:Failing CI run for reference: https://github.com/xarray-contrib/xarray-spatial/actions/runs/25926750990
The fix swaps
tempfile.TemporaryDirectory()for thetmp_pathpytest fixture used by the other seven tests in the same file.tmp_pathdefers cleanup to pytest's session-end sweep, which tolerates the still-open handle. Library behaviour is unchanged; the mmap cache holding the handle pastclose()is by design (performance).Test plan
pytest xrspatial/geotiff/tests/test_writer_return_path_1938.pypasses locally (Linux)