merge master

This commit is contained in:
debugtalk
2022-06-17 19:56:43 +08:00
5 changed files with 16 additions and 8 deletions

View File

@@ -8,6 +8,8 @@
- fix: filter commented out functions when generating plugin file
- fix: failed to use parameters in referenced testcase
- fix: failed to run testcase if python3 is not available on windows
- fix: panic occurred when running API step failed
- fix: step name overrides referenced testcase name
**python version**

View File

@@ -97,11 +97,11 @@ func (s *StepAPIWithOptionalArgs) Run(r *SessionRunner) (*StepResult, error) {
extendWithAPI(s.step, api)
stepResult, err := runStepRequest(r, s.step)
stepResult.StepType = stepTypeAPI
if err != nil {
r.summary.Success = false
return nil, err
return stepResult, err
}
stepResult.StepType = stepTypeAPI
return stepResult, nil
}

View File

@@ -46,6 +46,7 @@ class SessionRunner(object):
__export: List[Text] = []
__step_results: List[StepResult] = []
__session_variables: VariablesMapping = {}
__is_reference: bool = False
# time
__start_at: float = 0
__duration: float = 0
@@ -58,6 +59,7 @@ class SessionRunner(object):
self.__session_variables = self.__session_variables or {}
self.__start_at = 0
self.__duration = 0
self.__is_reference = self.__is_reference or False
self.__project_meta = self.__project_meta or load_project_meta(
self.__config.path
@@ -77,6 +79,10 @@ class SessionRunner(object):
def get_config(self) -> TConfig:
return self.__config
def set_references(self) -> "SessionRunner":
self.__is_reference = True
return self
def with_case_id(self, case_id: Text) -> "SessionRunner":
self.case_id = case_id
return self
@@ -193,7 +199,7 @@ class SessionRunner(object):
)
time.sleep(step.retry_interval)
logger.info(
f"run step retry ({i+1}/{step.retry_times} time): {step.name()} >>>>>>"
f"run step retry ({i + 1}/{step.retry_times} time): {step.name()} >>>>>>"
)
# save extracted variables to session variables
@@ -209,7 +215,7 @@ class SessionRunner(object):
self.__init()
self.__parse_config(param)
if ALLURE is not None:
if ALLURE is not None and not self.__is_reference:
# update allure report meta
ALLURE.dynamic.title(self.__config.name)
ALLURE.dynamic.description(f"TestCase ID: {self.case_id}")

View File

@@ -118,7 +118,7 @@ def run_step_request(runner: HttpRunner, step: TStep) -> StepResult:
for k, v in parsed_request_dict.items():
request_print += f"{k}: {pretty_format(v)}\n"
print(request_print)
logger.info(request_print)
if ALLURE is not None:
ALLURE.attach(
request_print,
@@ -134,11 +134,11 @@ def run_step_request(runner: HttpRunner, step: TStep) -> StepResult:
try:
resp_body = resp.json()
except requests.exceptions.JSONDecodeError:
except (requests.exceptions.JSONDecodeError, json.decoder.JSONDecodeError):
resp_body = resp.content
response_print += f"body: {pretty_format(resp_body)}\n"
print(response_print)
logger.info(response_print)
if ALLURE is not None:
ALLURE.attach(
response_print,

View File

@@ -22,7 +22,7 @@ def run_step_testcase(runner: HttpRunner, step: TStep) -> StepResult:
# step.testcase is a referenced testcase, e.g. RequestWithFunctions
ref_case_runner = step.testcase()
ref_case_runner.with_session(runner.session).with_case_id(
ref_case_runner.set_references().with_session(runner.session).with_case_id(
runner.case_id
).with_variables(step_variables).with_export(step_export).test_start()