mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-04 23:16:57 +08:00
fix: remove misuse of NoReturn in Python typing
This commit is contained in:
+9
-2
@@ -3,9 +3,16 @@
|
|||||||
## 4.0.0
|
## 4.0.0
|
||||||
|
|
||||||
- refactor: merge [hrp] into httprunner repo
|
- refactor: merge [hrp] into httprunner repo
|
||||||
- fix: call referenced api/testcase with relative path
|
|
||||||
- fix: ignore exceptions when reporting GA events
|
**go version**
|
||||||
|
|
||||||
- change: integrate [sentry sdk][sentry sdk] for panic reporting and analysis
|
- change: integrate [sentry sdk][sentry sdk] for panic reporting and analysis
|
||||||
|
- fix: call referenced api/testcase with relative path
|
||||||
|
|
||||||
|
**python version**
|
||||||
|
|
||||||
|
- fix: ignore exceptions when reporting GA events
|
||||||
|
- fix: remove misuse of NoReturn in Python typing
|
||||||
|
|
||||||
## hrp-v0.8.0 (2022-03-22)
|
## hrp-v0.8.0 (2022-03-22)
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ For compatibility, you can also write upload test script in old way:
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Text, NoReturn
|
from typing import Text
|
||||||
|
|
||||||
from httprunner.models import TStep, FunctionsMapping
|
from httprunner.models import TStep, FunctionsMapping
|
||||||
from httprunner.parser import parse_variables_mapping
|
from httprunner.parser import parse_variables_mapping
|
||||||
@@ -75,7 +75,7 @@ def ensure_upload_ready():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def prepare_upload_step(step: TStep, functions: FunctionsMapping) -> "NoReturn":
|
def prepare_upload_step(step: TStep, functions: FunctionsMapping):
|
||||||
""" preprocess for upload test
|
""" preprocess for upload test
|
||||||
replace `upload` info with MultipartEncoder
|
replace `upload` info with MultipartEncoder
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -2,7 +2,7 @@ import os
|
|||||||
import string
|
import string
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from typing import Dict, List, NoReturn, Set, Text, Tuple
|
from typing import Dict, List, Set, Text, Tuple
|
||||||
|
|
||||||
import jinja2
|
import jinja2
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@@ -133,7 +133,7 @@ def ensure_file_abs_path_valid(file_abs_path: Text) -> Text:
|
|||||||
return new_file_path
|
return new_file_path
|
||||||
|
|
||||||
|
|
||||||
def __ensure_testcase_module(path: Text) -> NoReturn:
|
def __ensure_testcase_module(path: Text):
|
||||||
""" ensure pytest files are in python module, generate __init__.py on demand
|
""" ensure pytest files are in python module, generate __init__.py on demand
|
||||||
"""
|
"""
|
||||||
init_file = os.path.join(os.path.dirname(path), "__init__.py")
|
init_file = os.path.join(os.path.dirname(path), "__init__.py")
|
||||||
@@ -158,7 +158,7 @@ def convert_testcase_path(testcase_abs_path: Text) -> Tuple[Text, Text]:
|
|||||||
return testcase_python_abs_path, name_in_title_case
|
return testcase_python_abs_path, name_in_title_case
|
||||||
|
|
||||||
|
|
||||||
def format_pytest_with_black(*python_paths: Text) -> NoReturn:
|
def format_pytest_with_black(*python_paths: Text):
|
||||||
logger.info("format pytest cases with black ...")
|
logger.info("format pytest cases with black ...")
|
||||||
try:
|
try:
|
||||||
if is_support_multiprocessing() or len(python_paths) <= 1:
|
if is_support_multiprocessing() or len(python_paths) <= 1:
|
||||||
@@ -436,7 +436,7 @@ def make_testcase(testcase: Dict, dir_path: Text = None) -> Text:
|
|||||||
return testcase_python_abs_path
|
return testcase_python_abs_path
|
||||||
|
|
||||||
|
|
||||||
def make_testsuite(testsuite: Dict) -> NoReturn:
|
def make_testsuite(testsuite: Dict):
|
||||||
"""convert valid testsuite dict to pytest folder with testcases"""
|
"""convert valid testsuite dict to pytest folder with testcases"""
|
||||||
# validate testsuite format
|
# validate testsuite format
|
||||||
load_testsuite(testsuite)
|
load_testsuite(testsuite)
|
||||||
@@ -493,7 +493,7 @@ def make_testsuite(testsuite: Dict) -> NoReturn:
|
|||||||
pytest_files_run_set.add(testcase_pytest_path)
|
pytest_files_run_set.add(testcase_pytest_path)
|
||||||
|
|
||||||
|
|
||||||
def __make(tests_path: Text) -> NoReturn:
|
def __make(tests_path: Text):
|
||||||
""" make testcase(s) with testcase/testsuite/folder absolute path
|
""" make testcase(s) with testcase/testsuite/folder absolute path
|
||||||
generated pytest file path will be cached in pytest_files_made_cache_mapping
|
generated pytest file path will be cached in pytest_files_made_cache_mapping
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from typing import Dict, Text, Any, NoReturn
|
from typing import Dict, Text, Any
|
||||||
|
|
||||||
import jmespath
|
import jmespath
|
||||||
import requests
|
import requests
|
||||||
@@ -153,7 +153,7 @@ class ResponseObject(object):
|
|||||||
}
|
}
|
||||||
if not expr.startswith(tuple(resp_obj_meta.keys())):
|
if not expr.startswith(tuple(resp_obj_meta.keys())):
|
||||||
return expr
|
return expr
|
||||||
|
|
||||||
try:
|
try:
|
||||||
check_value = jmespath.search(expr, resp_obj_meta)
|
check_value = jmespath.search(expr, resp_obj_meta)
|
||||||
except JMESPathError as ex:
|
except JMESPathError as ex:
|
||||||
@@ -193,7 +193,7 @@ class ResponseObject(object):
|
|||||||
validators: Validators,
|
validators: Validators,
|
||||||
variables_mapping: VariablesMapping = None,
|
variables_mapping: VariablesMapping = None,
|
||||||
functions_mapping: FunctionsMapping = None,
|
functions_mapping: FunctionsMapping = None,
|
||||||
) -> NoReturn:
|
):
|
||||||
|
|
||||||
variables_mapping = variables_mapping or {}
|
variables_mapping = variables_mapping or {}
|
||||||
functions_mapping = functions_mapping or {}
|
functions_mapping = functions_mapping or {}
|
||||||
|
|||||||
+9
-10
@@ -2,7 +2,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import List, Dict, Text, NoReturn
|
from typing import List, Dict, Text
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import allure
|
import allure
|
||||||
@@ -55,7 +55,7 @@ class HttpRunner(object):
|
|||||||
# log
|
# log
|
||||||
__log_path: Text = ""
|
__log_path: Text = ""
|
||||||
|
|
||||||
def __init_tests__(self) -> NoReturn:
|
def __init_tests__(self):
|
||||||
self.__config = self.config.perform()
|
self.__config = self.config.perform()
|
||||||
self.__teststeps = []
|
self.__teststeps = []
|
||||||
for step in self.teststeps:
|
for step in self.teststeps:
|
||||||
@@ -88,9 +88,7 @@ class HttpRunner(object):
|
|||||||
self.__export = export
|
self.__export = export
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __call_hooks(
|
def __call_hooks(self, hooks: Hooks, step_variables: VariablesMapping, hook_msg: Text):
|
||||||
self, hooks: Hooks, step_variables: VariablesMapping, hook_msg: Text,
|
|
||||||
) -> NoReturn:
|
|
||||||
""" call hook actions.
|
""" call hook actions.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@@ -139,11 +137,12 @@ class HttpRunner(object):
|
|||||||
step_data = StepData(name=step.name)
|
step_data = StepData(name=step.name)
|
||||||
|
|
||||||
# parse
|
# parse
|
||||||
prepare_upload_step(step, self.__project_meta.functions)
|
functions = self.__project_meta.functions
|
||||||
|
# prepare_upload_step(step, functions)
|
||||||
request_dict = step.request.dict()
|
request_dict = step.request.dict()
|
||||||
request_dict.pop("upload", None)
|
request_dict.pop("upload", None)
|
||||||
parsed_request_dict = parse_data(
|
parsed_request_dict = parse_data(
|
||||||
request_dict, step.variables, self.__project_meta.functions
|
request_dict, step.variables, functions
|
||||||
)
|
)
|
||||||
parsed_request_dict["headers"].setdefault(
|
parsed_request_dict["headers"].setdefault(
|
||||||
"HRUN-Request-ID",
|
"HRUN-Request-ID",
|
||||||
@@ -195,7 +194,7 @@ class HttpRunner(object):
|
|||||||
|
|
||||||
# extract
|
# extract
|
||||||
extractors = step.extract
|
extractors = step.extract
|
||||||
extract_mapping = resp_obj.extract(extractors, step.variables, self.__project_meta.functions)
|
extract_mapping = resp_obj.extract(extractors, step.variables, functions)
|
||||||
step_data.export_vars = extract_mapping
|
step_data.export_vars = extract_mapping
|
||||||
|
|
||||||
variables_mapping = step.variables
|
variables_mapping = step.variables
|
||||||
@@ -206,7 +205,7 @@ class HttpRunner(object):
|
|||||||
session_success = False
|
session_success = False
|
||||||
try:
|
try:
|
||||||
resp_obj.validate(
|
resp_obj.validate(
|
||||||
validators, variables_mapping, self.__project_meta.functions
|
validators, variables_mapping, functions
|
||||||
)
|
)
|
||||||
session_success = True
|
session_success = True
|
||||||
except ValidationFailure:
|
except ValidationFailure:
|
||||||
@@ -304,7 +303,7 @@ class HttpRunner(object):
|
|||||||
logger.info(f"run step end: {step.name} <<<<<<\n")
|
logger.info(f"run step end: {step.name} <<<<<<\n")
|
||||||
return step_data.export_vars
|
return step_data.export_vars
|
||||||
|
|
||||||
def __parse_config(self, config: TConfig) -> NoReturn:
|
def __parse_config(self, config: TConfig):
|
||||||
config.variables.update(self.__session_variables)
|
config.variables.update(self.__session_variables)
|
||||||
config.variables = parse_variables_mapping(
|
config.variables = parse_variables_mapping(
|
||||||
config.variables, self.__project_meta.functions
|
config.variables, self.__project_meta.functions
|
||||||
|
|||||||
Reference in New Issue
Block a user