mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 05:19:38 +08:00
fix locust in testsuite
This commit is contained in:
@@ -244,21 +244,27 @@ def prepare_locust_tests(path):
|
||||
parsed_tests_mapping = parser.parse_tests(tests_mapping)
|
||||
|
||||
functions = parsed_tests_mapping.get("project_mapping", {}).get("functions", {})
|
||||
testcase = parsed_tests_mapping["testcases"][0]
|
||||
items = testcase.get("teststeps", [])
|
||||
|
||||
tests = []
|
||||
for item in items:
|
||||
if "config" in item:
|
||||
# embeded testcase
|
||||
weight = item["config"].get("weight", 1)
|
||||
else:
|
||||
# API test
|
||||
weight = item.get("weight", 1)
|
||||
|
||||
# implement weight for tests
|
||||
for _ in range(weight):
|
||||
tests.append(item)
|
||||
for testcase in parsed_tests_mapping["testcases"]:
|
||||
testcase_weight = testcase.get("config", {}).get("weight", 1)
|
||||
items = testcase.get("teststeps", [])
|
||||
|
||||
testcase_tests = []
|
||||
for item in items:
|
||||
if "config" in item:
|
||||
# embeded testcase
|
||||
weight = item["config"].get("weight", 1)
|
||||
else:
|
||||
# API test
|
||||
weight = item.get("weight", 1)
|
||||
|
||||
# implement weight for tests
|
||||
for _ in range(weight):
|
||||
testcase_tests.append(item)
|
||||
|
||||
tests.extend(testcase_tests * testcase_weight)
|
||||
|
||||
return {
|
||||
"functions": functions,
|
||||
|
||||
@@ -942,6 +942,9 @@ def __get_parsed_testsuite_testcases(testcases, testsuite_config, project_mappin
|
||||
parsed_testcase["path"] = testcase["testcase"]
|
||||
parsed_testcase["config"]["name"] = testcase_name
|
||||
|
||||
if "weight" in testcase:
|
||||
parsed_testcase["config"]["weight"] = testcase["weight"]
|
||||
|
||||
# base_url priority: testcase config > testsuite config
|
||||
parsed_testcase["config"].setdefault("base_url", testsuite_base_url)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user