From ae021b6c2dff497ffd5914651841bcff9c2b548a Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Tue, 23 Jan 2024 17:15:51 +0100 Subject: [PATCH] Implement correctly fake_import in test_on_slave.py *args and **kwargs must be forwarded to __import__ otherwise the import context (global & local) can be incomplete to find local paths of external modules. In this situation, "ValueError: Empty module name" is thrown. Signed-off-by: Ronan Abhamon --- tests/test_on_slave.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_on_slave.py b/tests/test_on_slave.py index 209556998..4b59f6323 100644 --- a/tests/test_on_slave.py +++ b/tests/test_on_slave.py @@ -23,9 +23,9 @@ class Test_on_slave_is_open(unittest.TestCase): 'blktap2' ] - def fake_import(self, name, *args): - print('Asked to import {}'.format(name)) - return self.mocks.get(name, self.real_import(name)) + def fake_import(self, *args, **kwargs): + print('Asked to import {}'.format(args[0])) + return self.mocks.get(args[0], self.real_import(*args, **kwargs)) def setUp(self): self.addCleanup(mock.patch.stopall)