fix(core): make subprocess and temporary file tests portable on Windows - #39664
Merged
ccurme (ccurme) merged 4 commits intoAug 18, 2026
Merged
Conversation
Contributor
|
This PR has been automatically closed because you are not assigned to the linked issue. Opening a PR before assignment is discouraged and is not an indication that it will be accepted. This process exists so maintainers can confirm a change is aligned with the project direction before contributors invest time implementing it. Please:
Maintainers: reopen this PR or remove the |
Closed
29 tasks
# Conflicts: # libs/core/tests/unit_tests/prompts/test_prompt.py
Merging this PR will not alter performance
Comparing Footnotes
|
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.
Both changes are complete and verified. Here's a summary of what was done in this PR (closes #39647):
Changes
1.
libs/core/tests/unit_tests/test_imports.py—test_importable_all_via_subprocessimport sys."python"string in thesubprocess.run([...])call withsys.executable.Why: On Windows, a bare
pythoninvocation from a subprocess can resolve to the base Windows PATH interpreter rather than the interpreter running the test (the activeuvenvironment). Since the test imports a module that may only be installed in theuvenvironment, this previously caused the subprocess import to fail on Windows. Usingsys.executableguarantees the subprocess uses the same active interpreter.2.
libs/core/tests/unit_tests/prompts/test_prompt.py—test_from_file_encodingfrom tempfile import NamedTemporaryFileimport.from pathlib import Path.tmp_pathfixture: the file is written withfile_path.write_text(template, encoding="cp1252")and subsequently read viaPromptTemplate.from_file(file_path, ...), which acceptsstr | Path.Why: The original test kept a
NamedTemporaryFileopen (the file handle stays active inside thewithblock) while attempting to reopen that same path. On Windows this triggers aPermissionErrordue to file locking. Usingtmp_pathwrites and closes the file before any subsequent reads, avoiding the lock entirely while keeping the temporary-file cleanup behavior.Verification
uv run pytest:2 passed.ruff checkandruff format --checkon both files: all checks passed.No public API signatures were changed — these are test-only modifications.