mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-31 21:39:41 +08:00
relocate testcase parser
This commit is contained in:
@@ -7,6 +7,7 @@ import hmac
|
||||
import imp
|
||||
import importlib
|
||||
import io
|
||||
import itertools
|
||||
import json
|
||||
import os.path
|
||||
import random
|
||||
@@ -577,6 +578,40 @@ def create_scaffold(project_path):
|
||||
logger.color_print(msg, "BLUE")
|
||||
|
||||
|
||||
def gen_cartesian_product(*args):
|
||||
""" generate cartesian product for lists
|
||||
@param
|
||||
(list) args
|
||||
[{"a": 1}, {"a": 2}],
|
||||
[
|
||||
{"x": 111, "y": 112},
|
||||
{"x": 121, "y": 122}
|
||||
]
|
||||
@return
|
||||
cartesian product in list
|
||||
[
|
||||
{'a': 1, 'x': 111, 'y': 112},
|
||||
{'a': 1, 'x': 121, 'y': 122},
|
||||
{'a': 2, 'x': 111, 'y': 112},
|
||||
{'a': 2, 'x': 121, 'y': 122}
|
||||
]
|
||||
"""
|
||||
if not args:
|
||||
return []
|
||||
elif len(args) == 1:
|
||||
return args[0]
|
||||
|
||||
product_list = []
|
||||
for product_item_tuple in itertools.product(*args):
|
||||
product_item_dict = {}
|
||||
for item in product_item_tuple:
|
||||
product_item_dict.update(item)
|
||||
|
||||
product_list.append(product_item_dict)
|
||||
|
||||
return product_list
|
||||
|
||||
|
||||
def validate_json_file(file_list):
|
||||
""" validate JSON testset format
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user