Skip to content

Fixed unit tests failure due to file access permission issue on Window OS - #84

Merged
ntgbaoo merged 1 commit into
mainfrom
bug/unit-tests-failure-permissionError-window
Jul 2, 2025
Merged

Fixed unit tests failure due to file access permission issue on Window OS#84
ntgbaoo merged 1 commit into
mainfrom
bug/unit-tests-failure-permissionError-window

Conversation

@ntgbaoo

@ntgbaoo ntgbaoo commented Jul 1, 2025

Copy link
Copy Markdown
Member

Purpose

Current unit tests are not compatible with Window OS due to the use of NamedTemporaryFile() . NamedTemporaryFile() keeps a file open and locked for exclusive access. Trying to open the temporary file with open() cause PermisionError.

Solution

As suggested here allenai/olmocr#74, an additional flag delete=False is added to each function call NamedTemporaryFile() . The side effect of this flag is that the temporal file will not be removed automatically. Hence, os.remove() is used to delete the temporary file manually.

Related PR

Fix #82

…w OS

Set delete=False in tempfile.NamedTemporaryFile and removed temp file manually at the end of the unit tests
@ntgbaoo
ntgbaoo requested a review from Jacob-Chmura July 1, 2025 19:35
@codecov

codecov Bot commented Jul 1, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@ntgbaoo
ntgbaoo requested a review from shenyangHuang July 1, 2025 19:36

@Jacob-Chmura Jacob-Chmura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for the patch. Hopefully not too many other platform issues arise.

@Jacob-Chmura

Copy link
Copy Markdown
Member

We may want to consider adding window's runners for our CI pipeline, to catch things like this

@ntgbaoo
ntgbaoo merged commit 6ec4121 into main Jul 2, 2025
6 checks passed
@ntgbaoo ntgbaoo self-assigned this Jul 3, 2025
@Jacob-Chmura
Jacob-Chmura deleted the bug/unit-tests-failure-permissionError-window branch August 19, 2025 11:54
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.

PermissionError in unit tests executed on a machine with Window OS

2 participants