common.py
记得好像如果yaml带config就会只导入config,
所以去掉config解析把,我只要test就好,config手动去加也快==
def upload_file_logic(files, project, module, account):
"""
解析yaml或者json用例
:param files:
:param project:
:param module:
:param account:
:return:
"""
logger.info('上传文件逻辑0-ditto*****************************')
for file in files:
file_suffix = os.path.splitext(file)[1].lower()
if file_suffix == '.json':
with io.open(file, encoding='utf-8') as data_file:
try:
content = json.load(data_file)
except JSONDecodeError:
err_msg = u"JSONDecodeError: JSON file format error: {}".format(file)
logging.error(err_msg)
elif file_suffix in ['.yaml', '.yml']:
with io.open(file, 'r', encoding='utf-8') as stream:
content = yaml.load(stream)
for test_case in content:
test_dict = {
'project': project,
'module': module,
'author': account,
'include': []
}
# if 'config' in test_case.keys():
# test_case.get('config')['config_info'] = test_dict
# logger.info('test_dictconfig---{}-ditto*****************************'.format(test_dict))
# add_config_data(type=True, **test_case)
if 'test' in test_case.keys(): # 忽略config
test_case.get('test')['case_info'] = test_dict
new_test_case = test_case
add_case_data(type=True, **new_test_case)
logger.info('上传文件逻辑1-ditto*****************************')
网友评论