mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-30 20:11:42 +08:00
update locusts with HttpRunner 2.0
This commit is contained in:
@@ -661,71 +661,3 @@ def load_tests(path, dot_env_path=None):
|
||||
tests_mapping["testcases"] = testcases_list
|
||||
|
||||
return tests_mapping
|
||||
|
||||
|
||||
def load_locust_tests(path, dot_env_path=None):
|
||||
""" load locust testcases
|
||||
|
||||
Args:
|
||||
path (str): testcase/testsuite file path.
|
||||
dot_env_path (str): specified .env file path
|
||||
|
||||
Returns:
|
||||
dict: locust testcases with weight
|
||||
{
|
||||
"config": {...},
|
||||
"tests": [
|
||||
# weight 3
|
||||
[teststep11],
|
||||
[teststep11],
|
||||
[teststep11],
|
||||
# weight 2
|
||||
[teststep21, teststep22],
|
||||
[teststep21, teststep22]
|
||||
]
|
||||
}
|
||||
|
||||
"""
|
||||
raw_testcase = load_file(path)
|
||||
load_project_tests(path, dot_env_path)
|
||||
|
||||
config = {}
|
||||
tests = []
|
||||
for item in raw_testcase:
|
||||
key, test_block = item.popitem()
|
||||
|
||||
if key == "config":
|
||||
config.update(test_block)
|
||||
elif key == "test":
|
||||
teststep = load_teststep(test_block)
|
||||
weight = test_block.get("weight", 1)
|
||||
for _ in range(weight):
|
||||
tests.append(teststep)
|
||||
|
||||
# parse config variables
|
||||
raw_config_variables = config.get("variables", [])
|
||||
|
||||
config_variables = parser.parse_data(
|
||||
raw_config_variables,
|
||||
{},
|
||||
project_mapping["functions"]
|
||||
)
|
||||
|
||||
# parse config name
|
||||
config["name"] = parser.parse_data(
|
||||
config.get("name", ""),
|
||||
config_variables,
|
||||
project_mapping["functions"]
|
||||
)
|
||||
|
||||
# parse config request
|
||||
config["request"] = parser.parse_data(
|
||||
config.get("request", {}),
|
||||
config_variables,
|
||||
project_mapping["functions"]
|
||||
)
|
||||
|
||||
return {
|
||||
"config": config,
|
||||
"tests": tests
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user