]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
tests/functional/.../testcase.py: better socketdir cleanup
authorVladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Sat, 25 Oct 2025 16:58:03 +0000 (19:58 +0300)
committerThomas Huth <thuth@redhat.com>
Mon, 3 Nov 2025 07:27:59 +0000 (08:27 +0100)
TemporaryDirectory prefer explicit call to .cleanup() (or
use context manager). Otherwise it may produce a warning like:

   /usr/lib/python3.10/tempfile.py:1008: \
     ResourceWarning: Implicitly cleaning up \
     <TemporaryDirectory '/tmp/qemu_func_test_sock_4esmf5ba'>

Currently, the only test using socket_dir() is
tests/functional/x86_64/test_vfio_user_client.py, and it does
print this warning, at least with python 3.10.12. With this commit,
the warning disappears.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251025165809.930670-2-vsementsov@yandex-team.ru>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/functional/qemu_test/testcase.py

index 2c0abde395785b4a92b78b95d52bccf9586466ab..a122acb56093806da9daabf8ec57a2acaf9c59ee 100644 (file)
@@ -233,7 +233,7 @@ class QemuBaseTest(unittest.TestCase):
         if "QEMU_TEST_KEEP_SCRATCH" not in os.environ:
             shutil.rmtree(self.workdir)
         if self.socketdir is not None:
-            shutil.rmtree(self.socketdir.name)
+            self.socketdir.cleanup()
             self.socketdir = None
         self.machinelog.removeHandler(self._log_fh)
         self.log.removeHandler(self._log_fh)