| |
@@ -1,5 +1,6 @@
|
| |
from unittest import mock
|
| |
import tempfile
|
| |
+ import os
|
| |
import unittest
|
| |
|
| |
import koji
|
| |
@@ -38,22 +39,24 @@
|
| |
self.task.get_nvrp('/dev/null/non_existent_path')
|
| |
|
| |
# empty file
|
| |
- with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
|
| |
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
|
| |
fp.write(b'')
|
| |
fp.close()
|
| |
with self.assertRaises(koji.GenericError):
|
| |
self.task.get_nvrp(fp.name)
|
| |
+ os.unlink(fp.name)
|
| |
|
| |
# empty xml
|
| |
- with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
|
| |
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
|
| |
fp.write(b'<?xml version="1.0"?><test></test>')
|
| |
fp.close()
|
| |
with self.assertRaises(koji.GenericError):
|
| |
self.task.get_nvrp(fp.name)
|
| |
+ os.unlink(fp.name)
|
| |
|
| |
def test_get_nrvp_correct(self):
|
| |
# minimal correct xml
|
| |
- with tempfile.NamedTemporaryFile(delete_on_close=False) as fp:
|
| |
+ with tempfile.NamedTemporaryFile(delete=False) as fp:
|
| |
fp.write(b'''<?xml version="1.0" encoding="utf-8"?>
|
| |
<image schemaversion="7.4" name="Fedora-34.0_disk">
|
| |
<profiles>
|
| |
@@ -70,6 +73,7 @@
|
| |
self.assertEqual(name, 'Fedora-34.0_disk')
|
| |
self.assertEqual(version, '1.0.0')
|
| |
self.assertEqual(profile, 'Base')
|
| |
+ os.unlink(fp.name)
|
| |
|
| |
def test_handler_correct(self, arches=None):
|
| |
if arches is None:
|
| |
Using python3.9 (default python of AlmaLinux9) there are two tests failing:
There is no
delete_on_close
option using python3.9 - https://docs.python.org/3.9/library/tempfile.htmlIn 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