tests: fix Windows tempfile re-open by using delete=False and explicit cleanup #611
+94
−20
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.
tests: fix Windows tempfile re-open by using delete=False and explicit cleanup
Summary
Fix Windows-specific test failures caused by reopening files created with
tempfile.NamedTemporaryFile(); on Windows these files are locked while open. Tests now usetempfile.NamedTemporaryFile(delete=False)and explicitos.unlink()cleanup so they can be reopened cross-platform.Files changed
lib/ollama-python/tests/test_type_serialization.pyandlib/ollama-python/tests/test_client.py.patches/0001-tests-fix-Windows-tempfile-re-open-by-using-delete-F.patchin this repo.PATCHES.md.Validation
Ran the full test suite on Windows with
OLLAMA_AVAILABLE=1and a project-localTMP/TEMPdirectory; all tests passed (89 passed). Coverage generated:htmlcov/andcoverage.xml.Motivation
Prevents platform-specific test flakes and makes CI robust across Windows runners.
Reproduce locally
PowerShell:
CI notes
windows-latestto the test matrix in GitHub Actions to catch platform-specific file-locking issues.Notes
ollama/ollama-python.