mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 08:02:42 +08:00
fixed: #931 unit test parameters
This commit is contained in:
@@ -4,7 +4,6 @@ from httprunner import __version__
|
||||
def get_httprunner_version():
|
||||
return __version__
|
||||
|
||||
|
||||
def sum_two(m, n):
|
||||
return m + n
|
||||
|
||||
@@ -15,3 +14,7 @@ def get_testcase_config_variables():
|
||||
|
||||
def get_testsuite_config_variables():
|
||||
return {"foo1": "testsuite_config_bar1", "foo2": "testsuite_config_bar2"}
|
||||
|
||||
|
||||
def get_app_version():
|
||||
return [3.1, 3.0]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
username,password
|
||||
test1,111111
|
||||
test2,222222
|
||||
test2,222222
|
||||
test3,333333
|
||||
|
@@ -612,7 +612,7 @@ def init_make_parser(subparsers):
|
||||
|
||||
def make_test_start_style(config: Dict) -> Text:
|
||||
test_start_style = ""
|
||||
if config["parameters"]:
|
||||
if "parameters" in config.keys():
|
||||
params = config["parameters"]
|
||||
test_start_style = f"""
|
||||
import pytest
|
||||
|
||||
@@ -37,6 +37,7 @@ class TConfig(BaseModel):
|
||||
base_url: BaseUrl = ""
|
||||
# Text: prepare variables in debugtalk.py, ${gen_variables()}
|
||||
variables: Union[VariablesMapping, Text] = {}
|
||||
parameters: Union[VariablesMapping, Text] = {}
|
||||
# setup_hooks: Hooks = []
|
||||
# teardown_hooks: Hooks = []
|
||||
export: Export = []
|
||||
|
||||
@@ -435,7 +435,8 @@ class HttpRunner(object):
|
||||
|
||||
# parse config name
|
||||
config_variables = self.__config.variables
|
||||
config_variables.update(parametrize)
|
||||
if parametrize:
|
||||
config_variables.update(parametrize)
|
||||
config_variables.update(self.__session_variables)
|
||||
self.__config.name = parse_data(
|
||||
self.__config.name, config_variables, self.__project_meta.functions
|
||||
|
||||
@@ -461,7 +461,7 @@ class TestParserBasic(unittest.TestCase):
|
||||
param = [
|
||||
{
|
||||
"user_agent": ["iOS/10.1", "iOS/10.2"],
|
||||
"username-password": "${parameterize(account.csv)}",
|
||||
"username-password": "${parameterize(request_methods/account.csv)}",
|
||||
"sum": "${add_two_nums(1, 2)}",
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user