relocate testcase parser

This commit is contained in:
debugtalk
2018-08-05 11:46:27 +08:00
parent df75b6df85
commit 243515a2ec
11 changed files with 694 additions and 703 deletions

View File

@@ -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
"""