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