From 2292b0d22432bb2214f698cd74316658081aad3e Mon Sep 17 00:00:00 2001 From: Kyr Shatskyy Date: Mon, 3 Jun 2019 18:26:55 +0200 Subject: [PATCH] config: add parameter for config load This patch makes it possible to load config file directly from the given path or data object, for testing purposes and allows to remove silly notification about missing teuthology.yaml file. Signed-off-by: Kyr Shatskyy --- teuthology/config.py | 8 +++++++- teuthology/provision/cloud/test/test_openstack.py | 5 ++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/teuthology/config.py b/teuthology/config.py index 16b698746a..2144db0a94 100644 --- a/teuthology/config.py +++ b/teuthology/config.py @@ -29,7 +29,13 @@ class YamlConfig(collections.MutableMapping): else: self._conf = dict() - def load(self): + def load(self, conf=None): + if conf: + if isinstance(conf, dict): + self._conf = conf + else: + self._conf = yaml.safe_load(conf) + return if os.path.exists(self.yaml_path): self._conf = yaml.safe_load(file(self.yaml_path)) else: diff --git a/teuthology/provision/cloud/test/test_openstack.py b/teuthology/provision/cloud/test/test_openstack.py index cc6afd4952..bd51667667 100644 --- a/teuthology/provision/cloud/test/test_openstack.py +++ b/teuthology/provision/cloud/test/test_openstack.py @@ -66,9 +66,8 @@ def get_fake_obj(mock_args=None, attributes=None): class TestOpenStackBase(object): - def setup(self): - config.load() - config.libcloud = deepcopy(test_config) + def setup(self, conf=dict(), test_config=test_config): + config.load(conf or dict(libcloud=deepcopy(test_config))) self.start_patchers() def start_patchers(self): -- 2.39.5