def test_from_env_vars(self): """Config is laoded from environment variables""" os.environ['KUYRUK_WORKER_MAX_LOAD'] = '21' try: config = Config() config.from_env_vars() self.assertEqual(config.WORKER_MAX_LOAD, 21) finally: del os.environ['KUYRUK_WORKER_MAX_LOAD']
def create_config(args): """Creates Config object and overrides it's values from args.""" config = Config() if args.config: # Load config file from command line option config.from_pyfile(args.config) else: # Load config file from environment variable env_config = os.environ.get('KUYRUK_CONFIG') if env_config: assert os.path.isabs(env_config) config.from_pyfile(env_config) config.from_env_vars() config.from_cmd_args(args) return config