From 9224ec860ac4ead60dc8ec26e36f42f25737d5a7 Mon Sep 17 00:00:00 2001 From: erlanggakrisnamukti Date: Tue, 17 Jul 2018 13:10:33 +0700 Subject: [PATCH] Erlangga Add team_configuration property (#72) * add get team configuration * change read json path --- locust/configuration.py | 6 ++++-- locust/core.py | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/locust/configuration.py b/locust/configuration.py index 4ab288dbd8..d34f5da620 100644 --- a/locust/configuration.py +++ b/locust/configuration.py @@ -14,14 +14,16 @@ class ClientConfiguration: config_data = None - def read_json(self): + def read_json(self, path=None): """ Will get the data of configuration as JSON. It reads configuration file once. """ if self.config_data is None: + if path is None: + path = CONFIG_PATH try: - with open((os.environ['PYTHONPATH'].split(os.pathsep))[-1] + CONFIG_PATH, "r") as data_file: + with open((os.environ['PYTHONPATH'].split(os.pathsep))[-1] + path, "r") as data_file: self.config_data = json.load(data_file) except Exception as err: logger.info(err) diff --git a/locust/core.py b/locust/core.py index c5ae32049e..f69443fd81 100644 --- a/locust/core.py +++ b/locust/core.py @@ -371,6 +371,13 @@ def configuration(self): """ return self.config.read_json() + def team_configuration(self, path): + """ + Reference to get_team_config func in configuration.py + """ + config = ClientConfiguration() + return config.get_team_config(path) + @property def runners(self): """