def test_v2raise(self): fd, fname = mkstemp('.json') f = os.fdopen(fd, 'w') f.write(json2file) f.close() # Unlink the file cl = JSONFileConfigLoader(fname, log=log) with nt.assert_raises(ValueError): cl.load_config()
def test_json(self): fd, fname = mkstemp('.json') f = os.fdopen(fd, 'w') f.write(json1file) f.close() # Unlink the file cl = JSONFileConfigLoader(fname, log=log) config = cl.load_config() self._check_conf(config)
def _load_config_files(cls, basefilename, path=None, log=None): """Load config files (py,json) by filename and path. yield each config object in turn. """ pyloader = PyFileConfigLoader(basefilename + '.py', path=path, log=log) jsonloader = JSONFileConfigLoader(basefilename + '.json', path=path, log=log) config = None for loader in [pyloader, jsonloader]: try: config = loader.load_config() except ConfigFileNotFound: pass except Exception: # try to get the full filename, but it will be empty in the # unlikely event that the error raised before filefind finished filename = loader.full_filename or basefilename # problem while running the file if log: log.error("Exception while loading config file %s", filename, exc_info=True) else: if log: log.debug("Loaded config file: %s", loader.full_filename) if config: yield config raise StopIteration