server_environment: Improve tests.common to allow redefinition of serv_config application

This commit is contained in:
Akim Juillerat 2020-02-13 11:02:29 +01:00
parent ae4f847912
commit 558509bf45
1 changed files with 4 additions and 4 deletions

View File

@ -44,13 +44,13 @@ class ServerEnvironmentCase(common.SavepointCase):
yield yield
@contextmanager @contextmanager
def load_config(self, public=None, secret=None): def load_config(self, public=None, secret=None, serv_config_class=server_env_mixin):
original_serv_config = server_env_mixin.serv_config original_serv_config = serv_config_class.serv_config
try: try:
with self.set_config_dir(None), self.set_env_variables(public, secret): with self.set_config_dir(None), self.set_env_variables(public, secret):
parser = server_env._load_config() parser = server_env._load_config()
server_env_mixin.serv_config = parser serv_config_class.serv_config = parser
yield yield
finally: finally:
server_env_mixin.serv_config = original_serv_config serv_config_class.serv_config = original_serv_config