Skip to content

Fix Windows temporary-file handling in CLI tests - #735

Open
mehulikhanra904-prog wants to merge 1 commit into
google:masterfrom
mehulikhanra904-prog:fix/windows-tempfile-tests-693
Open

mehulikhanra904-prog wants to merge 1 commit into
google:masterfrom
mehulikhanra904-prog:fix/windows-tempfile-tests-693

Conversation

@mehulikhanra904-prog

Copy link
Copy Markdown

Summary

This PR fixes Windows-specific test failures in fire/main_test.py related to temporary file handling.

Changes Made

  • Set delete=False when creating temporary Python files.
  • Explicitly close temporary files before they are accessed by the import machinery.
  • Register cleanup callbacks using addCleanup(os.unlink, ...) to ensure temporary files are removed after tests.
  • Maintain compatibility with older supported Python versions.

Related Issue

Closes/Fixes: #693 (Windows temporary-file PermissionError).

Testing

  • Updated the test setup to avoid Windows file-locking issues.
  • Automated tests have not yet been executed on Windows.
  • CI validation is required.

Motivation

Windows does not allow reopening certain named temporary files while they remain open. Closing the files before importing them prevents the reported PermissionError and makes the test setup more cross-platform friendly.

@google-cla

google-cla Bot commented Nov 18, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test suite fails on Windows: unescaped path regex in testArgPassing, NamedTemporaryFile reopen in testFileNameFire

1 participant