Skip to content

Commit

Permalink
Implement correctly fake_import in test_on_slave.py
Browse files Browse the repository at this point in the history
*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 <[email protected]>
  • Loading branch information
Wescoeur committed Feb 12, 2024
1 parent 3f3eba6 commit 0b1d31b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tests/test_on_slave.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0b1d31b

Please sign in to comment.