예제 #1
0
 def test_load_module(self):
     hook = sandbox.CModuleImportHook([])
     self.assertRaises(ImportError, hook.load_module, 'lxml')
예제 #2
0
 def test_find_module_not_whitelisted_enabled_via_libaries(self):
     hook = sandbox.CModuleImportHook([re.compile(r'__builtin__')])
     self.assertIsNone(hook.find_module('__builtin__'))
예제 #3
0
 def test_find_module_not_whitelisted(self):
     hook = sandbox.CModuleImportHook([])
     self.assertEqual(hook, hook.find_module('__builtin__'))
예제 #4
0
 def test_find_module_whitelisted(self):
     hook = sandbox.CModuleImportHook([])
     for name in sandbox._WHITE_LIST_C_MODULES:
         self.assertIsNone(hook.find_module(name))
예제 #5
0
 def test_find_module_not_c_module(self):
     hook = sandbox.CModuleImportHook([])
     self.assertIsNone(hook.find_module('httplib'))
예제 #6
0
 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__))