Attempt at cleaning up issues introduced by new basic.py unit tests

pull/14740/head
James Cammarata 9 years ago
parent e011f52557
commit 1de9357c2f

@ -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…
Cancel
Save