From 988e7e6e781b0b2e30cd2ed6c6c34e80831fda46 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 22 May 2020 13:13:46 +0800 Subject: [PATCH] fix: parse config name --- httprunner/loader.py | 7 +++++-- httprunner/runner.py | 15 +++++++++------ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/httprunner/loader.py b/httprunner/loader.py index 937fabb0..5e6234ed 100644 --- a/httprunner/loader.py +++ b/httprunner/loader.py @@ -410,6 +410,11 @@ def load_project_meta(test_path: Text) -> ProjectMeta: environments and debugtalk.py functions. """ + project_meta = ProjectMeta() + + if not test_path: + return project_meta + if test_path in project_meta_cached_mapping: return project_meta_cached_mapping[test_path] @@ -417,8 +422,6 @@ def load_project_meta(test_path: Text) -> ProjectMeta: test_path ) - project_meta = ProjectMeta() - # load .env file # NOTICE: # environment variable maybe loaded in debugtalk.py diff --git a/httprunner/runner.py b/httprunner/runner.py index 0966749f..f3f2fb3c 100644 --- a/httprunner/runner.py +++ b/httprunner/runner.py @@ -174,11 +174,6 @@ class HttpRunner(object): return step_data.export def __parse_config(self, config: TConfig): - if config.path: - self.__project_meta = load_project_meta(config.path) - elif not self.__project_meta: - self.__project_meta = ProjectMeta() - config.variables.update(self.__session_variables) config.variables = parse_variables_mapping( config.variables, self.__project_meta.functions @@ -196,6 +191,7 @@ class HttpRunner(object): self.teststeps = testcase.teststeps # prepare + self.__project_meta = self.__project_meta or load_project_meta(self.config.path) self.__parse_config(self.config) self.__start_at = time.time() self.__step_datas: List[StepData] = [] @@ -271,8 +267,15 @@ class HttpRunner(object): ) log_handler = logger.add(self.__log_path, level="DEBUG") + # parse config name + self.__project_meta = self.__project_meta or load_project_meta(self.config.path) + variables = self.config.variables + variables.update(self.__session_variables) + self.config.name = parse_data( + self.config.name, variables, self.__project_meta.functions + ) + # update allure report meta - # TODO: parse config name allure.dynamic.title(self.config.name) allure.dynamic.description(f"TestCase ID: {self.__case_id}")