summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2021-10-20 18:30:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-23 17:42:28 +0100
commitc7d6f9965ebed60f7c5a28cadc8b26ed8f8828f9 (patch)
tree30e1e5ce6db8b6ea6d2b35d1243c6dc7bcf90f4a /meta/lib
parent676757f1872058e83336577e5c768b7c70aea9f0 (diff)
downloadpoky-c7d6f9965ebed60f7c5a28cadc8b26ed8f8828f9.tar.gz
oeqa/runtime: load modules using importlib
Instead of using __import__() which is low-level and discouraged, use importlib. (From OE-Core rev: 9f501d22eab5dbd565f3f5783f4f484a6d1f70a2) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/runtime/context.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 3826f27642..7908ce1fd4 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -175,16 +175,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
175 # Search for and return a controller or None from given module name 175 # Search for and return a controller or None from given module name
176 @staticmethod 176 @staticmethod
177 def _loadControllerFromModule(target, modulename): 177 def _loadControllerFromModule(target, modulename):
178 obj = None
179 # import module, allowing it to raise import exception
180 module = __import__(modulename, globals(), locals(), [target])
181 # look for target class in the module, catching any exceptions as it
182 # is valid that a module may not have the target class.
183 try: 178 try:
184 obj = getattr(module, target) 179 import importlib
185 except: 180 module = importlib.import_module(modulename)
186 obj = None 181 return getattr(module, target)
187 return obj 182 except AttributeError:
183 return None
188 184
189 @staticmethod 185 @staticmethod
190 def readPackagesManifest(manifest): 186 def readPackagesManifest(manifest):