mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Attempt at cleaning up issues introduced by new basic.py unit tests
This commit is contained in:
parent
e011f52557
commit
1de9357c2f
1 changed files with 3 additions and 2 deletions
|
@ -88,6 +88,8 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
||||||
def _mock_import(name, *args, **kwargs):
|
def _mock_import(name, *args, **kwargs):
|
||||||
if name == 'json':
|
if name == 'json':
|
||||||
raise ImportError
|
raise ImportError
|
||||||
|
elif name == 'simplejson':
|
||||||
|
return MagicMock()
|
||||||
return realimport(name, *args, **kwargs)
|
return realimport(name, *args, **kwargs)
|
||||||
|
|
||||||
self.clear_modules(['json', 'ansible.module_utils.basic'])
|
self.clear_modules(['json', 'ansible.module_utils.basic'])
|
||||||
|
@ -109,8 +111,7 @@ class TestModuleUtilsBasic(unittest.TestCase):
|
||||||
return realimport(name, *args, **kwargs)
|
return realimport(name, *args, **kwargs)
|
||||||
|
|
||||||
mock_import.side_effect = _mock_import
|
mock_import.side_effect = _mock_import
|
||||||
del sys.modules['ast']
|
self.clear_modules(['ast', 'ansible.module_utils.basic'])
|
||||||
del sys.modules['ansible.module_utils.basic']
|
|
||||||
mod = builtins.__import__('ansible.module_utils.basic')
|
mod = builtins.__import__('ansible.module_utils.basic')
|
||||||
self.assertEqual(mod.module_utils.basic.literal_eval("'1'"), "1")
|
self.assertEqual(mod.module_utils.basic.literal_eval("'1'"), "1")
|
||||||
self.assertEqual(mod.module_utils.basic.literal_eval("1"), 1)
|
self.assertEqual(mod.module_utils.basic.literal_eval("1"), 1)
|
||||||
|
|
Loading…
Reference in a new issue