fixed: #931 unit test parameters

This commit is contained in:
jun
2020-07-03 10:23:10 +08:00
parent 1c23d20933
commit 4595022f62
6 changed files with 11 additions and 5 deletions

View File

@@ -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]

View File

@@ -1,3 +1,4 @@
username,password
test1,111111
test2,222222
test2,222222
test3,333333
1 username password
2 test1 111111
3 test2 222222
4 test3 333333

View File

@@ -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

View File

@@ -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 = []

View File

@@ -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

View File

@@ -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)}",
}
]