Commit 75d32f08 by taoke

优化读取excle,若excle标题错误,则返回一串空列表

parent bc07b353
...@@ -27,11 +27,9 @@ def get_excelData(workBook,sheetName,caseName): ...@@ -27,11 +27,9 @@ def get_excelData(workBook,sheetName,caseName):
num_creator = list_title.index('creator') num_creator = list_title.index('creator')
num_autoCreator = list_title.index('autoCreator') num_autoCreator = list_title.index('autoCreator')
lis = [] lis = []
idx = 0 idx = 0
try:
for one in workSheet.col_values(0): for one in workSheet.col_values(0):
result = ''.join(re.findall(r'[A-Za-z]', one)) # 抽取字母字符串 result = ''.join(re.findall(r'[A-Za-z]', one)) # 抽取字母字符串
if caseName == result: if caseName == result:
...@@ -78,14 +76,17 @@ def get_excelData(workBook,sheetName,caseName): ...@@ -78,14 +76,17 @@ def get_excelData(workBook,sheetName,caseName):
idx += 1 idx += 1
return lis return lis
except: except:
print("excle中header值或参数或期望不是json字符串") list0=[{'url': '', 'headers': None, 'method': 'post', 'reqData': None, 'expectData': None, 'testPoint': '', 'caseNum': '', 'otherExpectData': None, 'function': '', 'interface': '', 'priority': '', 'yapiAddress': '', 'creator': '', 'autoCreator': '', 'frontInterface': '', 'frontCondition': '', 'expectResult': ''}]
except:
print("检查excle中标题是否正确") print("检查excle中标题是否正确")
return list0
if __name__ == '__main__': if __name__ == '__main__':
workBook = xlrd.open_workbook('../../test_case_data/bmc/bmc_testcase_20210513.xlsx') workBook = xlrd.open_workbook('../../test_case_data/bmc/bmc_testcase_20210513.xlsx')
li = get_excelData(workBook,"积分商城","focusSuccessIntegral") li = get_excelData(workBook,"账号信息基本功能","login")
print(li) for i in li :
print(i)
# {"Authorization": "","Content-Type":"application/x-www-form-urlencoded"} # {"Authorization": "","Content-Type":"application/x-www-form-urlencoded"}
\ No newline at end of file
...@@ -26,10 +26,10 @@ if __name__ == "__main__": ...@@ -26,10 +26,10 @@ if __name__ == "__main__":
# 生成报告数据 # 生成报告数据
pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp']) pytest.main(['-v', '-s', test_case_dir, '--alluredir', './report/tmp'])
# 打开报告 # 打开报告
os.system('allure serve ./report/tmp') # os.system('allure serve ./report/tmp')
# 发送钉钉 () # 发送钉钉 ()
# dingTalk.dingTalk_markdown(secret="SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3", dingTalk.dingTalk_markdown(secret="SEC465015385218e70a94f107a16f72dd33d8fc118c3b2a631e0433685302f2fbb3",
# webhook="https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee", webhook="https://oapi.dingtalk.com/robot/send?access_token=229908a83825ed56abbf728d3382e446a4e8a90e9ad302c37a036bcbccbbf9ee",
# message="") message="")
...@@ -15,7 +15,7 @@ from config import BMCConfig ...@@ -15,7 +15,7 @@ from config import BMCConfig
@allure.epic("账号信息基本功能") @allure.epic("账号信息基本功能")
# @allure.feature("账号信息基本功能") # @allure.feature("账号信息基本功能")
class TestLogin(): class TestLogin():
workBook = xlrd.open_workbook(f'{BMCConfig.root_path}/test_case_data/bmc/bmc_base_info_2021513.xlsx') workBook = xlrd.open_workbook(f'{BMCConfig.root_path}/test_case_data/bmc/bmc_testcase_20210513.xlsx')
@allure.story("账号信息基本功能") @allure.story("账号信息基本功能")
@allure.severity("") @allure.severity("")
@allure.title("{inData[testPoint]}") @allure.title("{inData[testPoint]}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment