From 41e2a0546f69deb491951372aeb545e57132f8b2 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Wed, 14 Jul 2021 21:36:44 +0800 Subject: [PATCH 1/5] fix #1059: data type hint correction reference runner.py: step_data.data = case_result.get_step_datas() # list of step data change: List[SessionData] --> List['StepData'] --- httprunner/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/httprunner/models.py b/httprunner/models.py index c4b60955..c35886c0 100644 --- a/httprunner/models.py +++ b/httprunner/models.py @@ -158,7 +158,7 @@ class StepData(BaseModel): success: bool = False name: Text = "" # teststep name - data: Union[SessionData, List[SessionData]] = None + data: Union[SessionData, List['StepData']] = None export_vars: VariablesMapping = {} From a519e60b680dabd51fddaa338e01b9d2cf3e6f43 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Thu, 15 Jul 2021 23:58:58 +0800 Subject: [PATCH 2/5] fix #1068: Variable name correction --- httprunner/make.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httprunner/make.py b/httprunner/make.py index b6726712..637e3de9 100644 --- a/httprunner/make.py +++ b/httprunner/make.py @@ -279,7 +279,7 @@ def make_teststep_chain_style(teststep: Dict) -> Text: step_info += f'.setup_hook("{hook}")' elif isinstance(hook, Dict) and len(hook) == 1: assign_var_name, hook_content = list(hook.items())[0] - step_info += f'.setup_hook("{hook}", "{assign_var_name}")' + step_info += f'.setup_hook("{hook_content}", "{assign_var_name}")' else: raise exceptions.TestCaseFormatError(f"Invalid setup hook: {hook}") @@ -297,7 +297,7 @@ def make_teststep_chain_style(teststep: Dict) -> Text: step_info += f'.teardown_hook("{hook}")' elif isinstance(hook, Dict) and len(hook) == 1: assign_var_name, hook_content = list(hook.items())[0] - step_info += f'.teardown_hook("{hook}", "{assign_var_name}")' + step_info += f'.teardown_hook("{hook_content}", "{assign_var_name}")' else: raise exceptions.TestCaseFormatError(f"Invalid teardown hook: {hook}") From 234b58758443e2a908b1b790f938764303c6ac6e Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Fri, 16 Jul 2021 13:56:23 +0800 Subject: [PATCH 3/5] fix: add class self-reference for variable annotations --- httprunner/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httprunner/models.py b/httprunner/models.py index c35886c0..e149e407 100644 --- a/httprunner/models.py +++ b/httprunner/models.py @@ -161,6 +161,9 @@ class StepData(BaseModel): data: Union[SessionData, List['StepData']] = None export_vars: VariablesMapping = {} + +StepData.update_forward_refs() + class TestCaseSummary(BaseModel): name: Text From 6be86e33f0d429984f915565788fafd2c12a3809 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Sun, 18 Jul 2021 15:53:03 +0800 Subject: [PATCH 4/5] fix: Resolve the FileNotFoundError while using subprocess on Windows --- tests/scaffold_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scaffold_test.py b/tests/scaffold_test.py index ee21cf51..2eea285d 100644 --- a/tests/scaffold_test.py +++ b/tests/scaffold_test.py @@ -18,7 +18,7 @@ class TestScaffold(unittest.TestCase): # run demo testcases try: - subprocess.check_call(["hrun", project_name]) + subprocess.check_call(["hrun", project_name], shell=True) except subprocess.SubprocessError: raise finally: From 4f860338fe091820d37270d21fa31b8082c24ea9 Mon Sep 17 00:00:00 2001 From: xucong053 <43516634+xucong053@users.noreply.github.com> Date: Sun, 18 Jul 2021 16:02:47 +0800 Subject: [PATCH 5/5] fix: bugfix --- tests/scaffold_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/scaffold_test.py b/tests/scaffold_test.py index 2eea285d..3a6b7073 100644 --- a/tests/scaffold_test.py +++ b/tests/scaffold_test.py @@ -2,6 +2,7 @@ import os import shutil import subprocess import unittest +import platform from httprunner.scaffold import create_scaffold @@ -18,7 +19,10 @@ class TestScaffold(unittest.TestCase): # run demo testcases try: - subprocess.check_call(["hrun", project_name], shell=True) + if platform.system() is "Windows": + subprocess.check_call(["hrun", project_name], shell=True) + else: + subprocess.check_call(["hrun", project_name]) except subprocess.SubprocessError: raise finally: