From fed8d5adaf838fbb37f0c0e36400a6f355d8704b Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 18 Jun 2020 17:19:34 +0800 Subject: [PATCH] change: add weight attribute in config --- httprunner/models.py | 1 + httprunner/testcase.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/httprunner/models.py b/httprunner/models.py index 0e20a494..edb2a559 100644 --- a/httprunner/models.py +++ b/httprunner/models.py @@ -41,6 +41,7 @@ class TConfig(BaseModel): # teardown_hooks: Hooks = [] export: Export = [] path: Text = None + weight: int = 1 class TRequest(BaseModel): diff --git a/httprunner/testcase.py b/httprunner/testcase.py index 03f8e68a..1efb63ec 100644 --- a/httprunner/testcase.py +++ b/httprunner/testcase.py @@ -17,18 +17,23 @@ class Config(object): self.__base_url = "" self.__verify = False self.__export = [] + self.__weight = 1 caller_frame = inspect.stack()[1] self.__path = caller_frame.filename @property - def name(self): + def name(self) -> Text: return self.__name @property - def path(self): + def path(self) -> Text: return self.__path + @property + def weight(self) -> int: + return self.__weight + def variables(self, **variables) -> "Config": self.__variables.update(variables) return self @@ -45,6 +50,10 @@ class Config(object): self.__export.extend(export_var_name) return self + def locust_weight(self, weight: int) -> "Config": + self.__weight = weight + return self + def perform(self) -> TConfig: return TConfig( name=self.__name, @@ -53,6 +62,7 @@ class Config(object): variables=self.__variables, export=list(set(self.__export)), path=self.__path, + weight=self.__weight, )