tests: fix Windows tempfile re-open by using delete=False and explicit cleanup#611
tests: fix Windows tempfile re-open by using delete=False and explicit cleanup#61173junito wants to merge 2 commits intoollama:mainfrom
Conversation
|
CI notes and patch link This PR fixes Windows-specific test failures by making tests use ReproductionPowerShell: $env:OLLAMA_AVAILABLE=1
$env:TMP=$pwd.Path + '\tmp'
$env:TEMP=$env:TMP
pytest --basetemp=tmp/pytest --cov --cov-branch --cov-report=xml --cov-report=htmlPatch (in the parent repo): Suggested CI change: add Example matrix snippet: strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]Notes
Notes
|
|
Requesting review from maintainers: this PR fixes Windows-specific test flakes by making tests reopenable on Windows. CI suggestion: add windows-latest to the test matrix. Patch available in autolearnpro branch fix/ollama-python-windows-tests: https://github.com/73junito/autolearnpro/blob/fix/ollama-python-windows-tests/patches/0001-tests-fix-Windows-tempfile-re-open-by-using-delete-F.patch. If you'd like, I can update the PR with additional CI changes or tests. |
|
Note: I added a CI matrix workflow that includes a Windows job (lib/ollama-python/.github/workflows/ci-matrix.yml) to run tests on ubuntu, windows, and macOS. This should detect Windows-specific tempfile file-lock flakes. The workflow is committed to branch 73junito:fix/windows-tempfile-tests. |
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.