mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 08:59:44 +08:00
refactor: rename to parameters
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
# NOTE: Generated By HttpRunner v3.1.3
|
||||
# FROM: request_methods/request_with_parameters.yml
|
||||
|
||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||
|
||||
|
||||
class TestCaseRequestWithParameters(HttpRunner):
|
||||
|
||||
import pytest
|
||||
from httprunner.parser import parse_parameters
|
||||
|
||||
param = [
|
||||
{
|
||||
"user_agent": ["iOS/10.1", "iOS/10.2"],
|
||||
"username-password": "${parameterize(request_methods/account.csv)}",
|
||||
"app_version": "${get_app_version()}",
|
||||
}
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("parameters", parse_parameters(param))
|
||||
def test_start(self, parameters):
|
||||
super().test_start(parameters)
|
||||
|
||||
config = (
|
||||
Config("request methods testcase: validate with parameters")
|
||||
.variables(**{"app_version": "f1"})
|
||||
.base_url("https://postman-echo.com")
|
||||
.verify(False)
|
||||
)
|
||||
|
||||
teststeps = [
|
||||
Step(
|
||||
RunRequest("get with params")
|
||||
.with_variables(
|
||||
**{
|
||||
"foo1": "$username",
|
||||
"foo2": "$password",
|
||||
"sum_v": "${sum_two(1, $app_version)}",
|
||||
}
|
||||
)
|
||||
.get("/get")
|
||||
.with_params(**{"foo1": "$foo1", "foo2": "$foo2", "sum_v": "$sum_v"})
|
||||
.with_headers(**{"User-Agent": "$user_agent,$app_version"})
|
||||
.extract()
|
||||
.with_jmespath("body.args.foo2", "session_foo2")
|
||||
.validate()
|
||||
.assert_equal("status_code", 200)
|
||||
.assert_string_equals("body.args.sum_v", "${sum_two(1, $app_version)}")
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
TestCaseRequestWithParameters().test_start()
|
||||
@@ -421,7 +421,7 @@ class HttpRunner(object):
|
||||
step_datas=self.__step_datas,
|
||||
)
|
||||
|
||||
def test_start(self, parametrize=None) -> "HttpRunner":
|
||||
def test_start(self, parameters: Dict = None) -> "HttpRunner":
|
||||
"""main entrance, discovered by pytest"""
|
||||
self.__init_tests__()
|
||||
self.__project_meta = self.__project_meta or load_project_meta(
|
||||
@@ -435,8 +435,8 @@ class HttpRunner(object):
|
||||
|
||||
# parse config name
|
||||
config_variables = self.__config.variables
|
||||
if parametrize:
|
||||
config_variables.update(parametrize)
|
||||
if parameters:
|
||||
config_variables.update(parameters)
|
||||
config_variables.update(self.__session_variables)
|
||||
self.__config.name = parse_data(
|
||||
self.__config.name, config_variables, self.__project_meta.functions
|
||||
|
||||
Reference in New Issue
Block a user