示例#1
0
 def test_autoload_client_from_path(self):
   with temppath() as module_path:
     self._write_client_module(module_path, 'PathClient')
     with temppath() as config_path:
       config = Config(config_path)
       config.add_section(config.global_section)
       config.set(config.global_section, 'autoload.paths', module_path)
       config._autoload()
       client = Client.from_options({'url': ''}, 'PathClient')
       eq_(client.one, 1)
示例#2
0
 def test_autoload_client_from_module(self):
   with temppath() as module_dpath:
     os.mkdir(module_dpath)
     sys.path.append(module_dpath)
     module_fpath = osp.join(module_dpath, 'mclient.py')
     self._write_client_module(module_fpath, 'ModuleClient')
     try:
       with temppath() as config_path:
         config = Config(config_path)
         config.add_section(config.global_section)
         config.set(config.global_section, 'autoload.modules', 'mclient')
         config._autoload()
         client = Client.from_options({'url': ''}, 'ModuleClient')
         eq_(client.one, 1)
     finally:
       sys.path.remove(module_dpath)