[1/2] testsuite: fix run_privileged_cmd in image account extension unit test

Message ID 20261026121844.663746-1-clara.kowalsky@siemens.com
State New
Headers show
Series [1/2] testsuite: fix run_privileged_cmd in image account extension unit test | expand

Commit Message

Clara Kowalsky Oct. 26, 2026, 12:18 p.m. UTC
The account functions use run_privileged_cmd which BitBake provides
through base.bbclass. The tests load the functions in isolation, so the
helper is undefined and the tests fail with:

NameError: name 'run_privileged_cmd' is not defined

Fix this by providing a stub for the helper in the test namespace.

Fixes: 14acf490 ("introduce wrappers for privileged execution")
Signed-off-by: Clara Kowalsky <clara.kowalsky@siemens.com>
---
 testsuite/unittests/test_image_account_extension.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch

diff --git a/testsuite/unittests/test_image_account_extension.py b/testsuite/unittests/test_image_account_extension.py
index ff0e47e0..ecadc15f 100644
--- a/testsuite/unittests/test_image_account_extension.py
+++ b/testsuite/unittests/test_image_account_extension.py
@@ -18,8 +18,15 @@  from bb import process
 from bb.data_smart import DataSmart
 
 file_name = 'meta/classes-recipe/image-account-extension.bbclass'
-image_create_users = load_function(file_name, 'image_create_users')
-image_create_groups = load_function(file_name, 'image_create_groups')
+
+
+def run_privileged_cmd(d):
+    return 'sudo -E'
+
+
+namespace = {'run_privileged_cmd': run_privileged_cmd}
+image_create_users = load_function(file_name, 'image_create_users', namespace)
+image_create_groups = load_function(file_name, 'image_create_groups', namespace)
 
 
 class TestImageAccountExtensionCommon(unittest.TestCase):