mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-12 16:01:27 +08:00
refactor: change param name
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from httprunner import parse_parameters
|
from httprunner import Parameters
|
||||||
|
|
||||||
|
|
||||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||||
@@ -11,8 +11,8 @@ from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
|||||||
|
|
||||||
class TestCaseRequestWithParameters(HttpRunner):
|
class TestCaseRequestWithParameters(HttpRunner):
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"parameters",
|
"param",
|
||||||
parse_parameters(
|
Parameters(
|
||||||
{
|
{
|
||||||
"user_agent": ["iOS/10.1", "iOS/10.2"],
|
"user_agent": ["iOS/10.1", "iOS/10.2"],
|
||||||
"username-password": "${parameterize(request_methods/account.csv)}",
|
"username-password": "${parameterize(request_methods/account.csv)}",
|
||||||
@@ -20,8 +20,8 @@ class TestCaseRequestWithParameters(HttpRunner):
|
|||||||
}
|
}
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
def test_start(self, parameters):
|
def test_start(self, param):
|
||||||
super().test_start(parameters)
|
super().test_start(param)
|
||||||
|
|
||||||
config = (
|
config = (
|
||||||
Config("request methods testcase: validate with parameters")
|
Config("request methods testcase: validate with parameters")
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ __description__ = "One-stop solution for HTTP(S) testing."
|
|||||||
|
|
||||||
# import firstly for monkey patch if needed
|
# import firstly for monkey patch if needed
|
||||||
from httprunner.ext.locust import main_locusts
|
from httprunner.ext.locust import main_locusts
|
||||||
from httprunner.parser import parse_parameters
|
from httprunner.parser import parse_parameters as Parameters
|
||||||
from httprunner.runner import HttpRunner
|
from httprunner.runner import HttpRunner
|
||||||
from httprunner.testcase import Config, Step, RunRequest, RunTestCase
|
from httprunner.testcase import Config, Step, RunRequest, RunTestCase
|
||||||
|
|
||||||
@@ -15,5 +15,5 @@ __all__ = [
|
|||||||
"Step",
|
"Step",
|
||||||
"RunRequest",
|
"RunRequest",
|
||||||
"RunTestCase",
|
"RunTestCase",
|
||||||
"parse_parameters",
|
"Parameters",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ sys.path.insert(0, str(Path(__file__){% for _ in range(diff_levels) %}.parent{%
|
|||||||
|
|
||||||
{% if parameters %}
|
{% if parameters %}
|
||||||
import pytest
|
import pytest
|
||||||
from httprunner import parse_parameters
|
from httprunner import Parameters
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
||||||
@@ -57,9 +57,9 @@ from httprunner import HttpRunner, Config, Step, RunRequest, RunTestCase
|
|||||||
class {{ class_name }}(HttpRunner):
|
class {{ class_name }}(HttpRunner):
|
||||||
|
|
||||||
{% if parameters %}
|
{% if parameters %}
|
||||||
@pytest.mark.parametrize('parameters', parse_parameters({{parameters}}))
|
@pytest.mark.parametrize("param", Parameters({{parameters}}))
|
||||||
def test_start(self, parameters):
|
def test_start(self, param):
|
||||||
super().test_start(parameters)
|
super().test_start(param)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
config = {{ config_chain_style }}
|
config = {{ config_chain_style }}
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ class HttpRunner(object):
|
|||||||
step_datas=self.__step_datas,
|
step_datas=self.__step_datas,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_start(self, parameters: Dict = None) -> "HttpRunner":
|
def test_start(self, param: Dict = None) -> "HttpRunner":
|
||||||
"""main entrance, discovered by pytest"""
|
"""main entrance, discovered by pytest"""
|
||||||
self.__init_tests__()
|
self.__init_tests__()
|
||||||
self.__project_meta = self.__project_meta or load_project_meta(
|
self.__project_meta = self.__project_meta or load_project_meta(
|
||||||
@@ -435,8 +435,8 @@ class HttpRunner(object):
|
|||||||
|
|
||||||
# parse config name
|
# parse config name
|
||||||
config_variables = self.__config.variables
|
config_variables = self.__config.variables
|
||||||
if parameters:
|
if param:
|
||||||
config_variables.update(parameters)
|
config_variables.update(param)
|
||||||
config_variables.update(self.__session_variables)
|
config_variables.update(self.__session_variables)
|
||||||
self.__config.name = parse_data(
|
self.__config.name = parse_data(
|
||||||
self.__config.name, config_variables, self.__project_meta.functions
|
self.__config.name, config_variables, self.__project_meta.functions
|
||||||
|
|||||||
Reference in New Issue
Block a user