From: Thomas Huth Date: Wed, 22 Jan 2025 13:43:13 +0000 (+0100) Subject: tests/functional/qemu_test/decorators: Fix bad check for imports X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=aca2c48e4d26426c14499fd3d8a2e333ac57d267;p=qemu.git tests/functional/qemu_test/decorators: Fix bad check for imports skipIfMissingImports should use importlib.import_module() for checking whether a module with the name stored in the "impname" variable is available or not, otherwise the code tries to import a module with the name "impname" instead. (This bug hasn't been noticed before since there is another issue with this decorator that will be fixed by the next patch) Suggested-by: Daniel P. Berrangé Reviewed-by: Daniel P. Berrangé Message-ID: <20250122134315.1448794-2-thuth@redhat.com> Signed-off-by: Thomas Huth --- diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py index df088bc090..08f58f6b40 100644 --- a/tests/functional/qemu_test/decorators.py +++ b/tests/functional/qemu_test/decorators.py @@ -2,6 +2,7 @@ # # Decorators useful in functional tests +import importlib import os import platform from unittest import skipUnless @@ -97,7 +98,7 @@ def skipIfMissingImports(*args): def has_imports(importlist): for impname in importlist: try: - import impname + importlib.import_module(impname) except ImportError: return False return True