diff options
author | Thomas Huth <thuth@redhat.com> | 2025-01-22 14:43:13 +0100 |
---|---|---|
committer | Thomas Huth <thuth@redhat.com> | 2025-01-30 10:30:36 +0100 |
commit | aca2c48e4d26426c14499fd3d8a2e333ac57d267 (patch) | |
tree | f74b99dcf492319aa1e7d36c4bf2169c8fd0a9cd /tests/functional/qemu_test | |
parent | 871af84dd599fab68c8ed414d9ecbdb2bcfc5801 (diff) | |
download | qemu-aca2c48e4d26426c14499fd3d8a2e333ac57d267.zip qemu-aca2c48e4d26426c14499fd3d8a2e333ac57d267.tar.gz qemu-aca2c48e4d26426c14499fd3d8a2e333ac57d267.tar.bz2 |
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é <berrange@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20250122134315.1448794-2-thuth@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Diffstat (limited to 'tests/functional/qemu_test')
-rw-r--r-- | tests/functional/qemu_test/decorators.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/functional/qemu_test/decorators.py b/tests/functional/qemu_test/decorators.py index df088bc..08f58f6 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 |