コード例 #1
0
ファイル: sandbox_test.py プロジェクト: girum11/hang
 def test_load_module(self):
   hook = sandbox.CModuleImportHook([])
   self.assertRaises(ImportError, hook.load_module, 'lxml')
コード例 #2
0
ファイル: sandbox_test.py プロジェクト: girum11/hang
 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__))
コード例 #3
0
ファイル: sandbox_test.py プロジェクト: startup-one/cogofly
 def test_find_module_not_whitelisted_enabled_via_libaries(self):
   hook = sandbox.CModuleImportHook([re.compile(r'__builtin__')])
   self.assertIsNone(hook.find_module('__builtin__'))
コード例 #4
0
ファイル: sandbox_test.py プロジェクト: startup-one/cogofly
 def test_find_module_not_whitelisted(self):
   hook = sandbox.CModuleImportHook([])
   self.assertEqual(hook, hook.find_module('__builtin__'))
コード例 #5
0
ファイル: sandbox_test.py プロジェクト: startup-one/cogofly
 def test_find_module_whitelisted(self):
   hook = sandbox.CModuleImportHook([])
   for name in sandbox._WHITE_LIST_C_MODULES:
     self.assertIsNone(hook.find_module(name))
コード例 #6
0
ファイル: sandbox_test.py プロジェクト: startup-one/cogofly
 def test_find_module_not_c_module(self):
   hook = sandbox.CModuleImportHook([])
   self.assertIsNone(hook.find_module('httplib'))