feat(): 优化项目
- 更新README - 修复bug
This commit is contained in:
@@ -24,8 +24,8 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
session = Session(settings.base_url)
|
||||
|
||||
|
||||
_case_path = Path(settings.case_path)
|
||||
|
||||
exchanger = Exchange(settings.exchanger)
|
||||
|
||||
|
||||
@@ -41,23 +41,24 @@ class TestAPI:
|
||||
"""
|
||||
yaml_path_list = case_path.glob("**/test_*.yaml") # 搜索当前目录及其子目录下以test_开头yaml为后缀的文件
|
||||
for yaml_path in yaml_path_list:
|
||||
logger.info(f"load file {yaml_path=}")
|
||||
# logger.info(f"load file {yaml_path=}")
|
||||
|
||||
file = YamlFile(yaml_path) # 自动读取yaml文件
|
||||
case_info = CaseInfo(**file) # 校验yaml格式
|
||||
|
||||
logger.debug(f"case_info={case_info.to_yaml()}") # 把case_info 转成字符串,然后记录日志
|
||||
# logger.info(f"case_info={case_info.to_yaml()}") # 把case_info 转成字符串,然后记录日志
|
||||
|
||||
case_func = cls.new_case(case_info) # 从yaml格式转换为pytest格式
|
||||
print(yaml_path.name)
|
||||
setattr(cls, f"{yaml_path.name}", case_func) # 把pytest格式添加到类中
|
||||
print(yaml_path.stem)
|
||||
setattr(cls, f"{yaml_path.stem}", case_func) # 把pytest格式添加到类中
|
||||
|
||||
@classmethod
|
||||
def new_case(cls, case_info: CaseInfo):
|
||||
ddt_data = case_info.ddt()
|
||||
print(ddt_data)
|
||||
ddt_title = [data.title for data in ddt_data]
|
||||
|
||||
ddt_title = [data.title for data in ddt_data]
|
||||
logger.info(f"{ddt_title=}")
|
||||
@allure.feature(case_info.feature)
|
||||
@allure.story(case_info.story)
|
||||
@pytest.mark.parametrize("case_info", ddt_data, ids=ddt_title)
|
||||
|
||||
Reference in New Issue
Block a user