def test_load_module(self): hook = sandbox.CModuleImportHook([]) self.assertRaises(ImportError, hook.load_module, 'lxml')
def test_find_module_not_whitelisted_enabled_via_libaries(self): hook = sandbox.CModuleImportHook([re.compile(r'__builtin__')]) self.assertIsNone(hook.find_module('__builtin__'))
def test_find_module_not_whitelisted(self): hook = sandbox.CModuleImportHook([]) self.assertEqual(hook, hook.find_module('__builtin__'))
def test_find_module_whitelisted(self): hook = sandbox.CModuleImportHook([]) for name in sandbox._WHITE_LIST_C_MODULES: self.assertIsNone(hook.find_module(name))
def test_find_module_not_c_module(self): hook = sandbox.CModuleImportHook([]) self.assertIsNone(hook.find_module('httplib'))
def test_find_module_disabled_module(self): hook = sandbox.CModuleImportHook([re.compile(r'numpy\.')]) self.assertIsNone(hook.find_module('lxml')) lxml = __import__('lxml') self.assertEqual(hook, hook.find_module('lxml.etree', lxml.__path__))