From dd6b82425a6454568615ef306c9755354c770986 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 bf34487134e89da7af41f24ffa2fff1c43ea26ba 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 cc666461161555d93a4632d96bdfbb829b959fbe 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 dd05e920fa8db1e59ea2ad3abc50916ea99f0b10 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 b583e3cce11ed28e3f6b49a908820d408a198de4 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: