Skip to content

Tests fail on Windows due to PermissionError with NamedTemporaryFile #1503

@denini08

Description

@denini08

I was running the tests on my Windows machine and noticed a failure in test/test_utils.py caused by NamedTemporaryFile being opened twice, which is not allowed on Windows because the file is already open with an exclusive handle. It happend in the fixtures safe_tar_file and unsafe_tar_file.

Here’s the error I got:

E           PermissionError: [Errno 13] Permission denied: 
E           'C:\\Users\\user\\AppData\\Local\\Temp\\tmpeqruskgx'

C:\hostedtoolcache\windows\Python\3.12.8\x64\Lib\gzip.py:192: PermissionError

This issue happens when the tests try to open a NamedTemporaryFile path again using tarfile.open() while the temporary file is still open.

On Linux this works fine, but on Windows it fails due to file locking behavior.

I’ll try to open a PR with a fix that makes it compatible with both systems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions