#4326 Remove fp file using os.unlink instead of using the delete option of NamedTemporaryFile
Merged by tkopecek. Opened by alisboav.
alisboav/koji issue-4320  into  master

Download 4326.patch

Using python3.9 (default python of AlmaLinux9) there are two tests failing:

=========================== short test summary info ============================
FAILED tests/test_plugins/test_kiwi_builder.py::TestKiwiBuildTask::test_get_nrvp_correct - TypeError: NamedTemporaryFile() got an unexpected keyword argument 'delete_...
FAILED tests/test_plugins/test_kiwi_builder.py::TestKiwiBuildTask::test_get_nrvp_invalid_xml - TypeError: NamedTemporaryFile() got an unexpected keyword argument 'delete_...
================== 2 failed, 2694 passed in 63.92s (0:01:03) ===================

There is no delete_on_close option using python3.9 - https://docs.python.org/3.9/library/tempfile.html

In python3.12:
> If delete is true (the default) and delete_on_close is false, the file is deleted on context manager exit only, or else when the file-like object is finalized.

The aims of this PR is to use os.unlink instead of the delete option of NamedTemporaryFile and make it work regardless of python version:

======================= 2696 passed in 61.69s (0:01:01) ========================

Fixes https://pagure.io/koji/issue/4320

Seems fine to me. This unit test is the only place we have used the option.

Actually this unit test goes against the normal pattern we have in most of our unit tests, which is to set up a temporary dir in setUp and remove it in tearDown. I think this fix is fine for now, but would be nice to bring this in line with the rest.

Metadata Update from @tkopecek:
- Pull-request tagged with: no_qe

Commit 9e2e7023 fixes this pull-request

Pull-Request has been merged by tkopecek

Metadata