添加初始化用例操作

This commit is contained in:
zy7y 2020-12-16 10:05:05 +08:00 committed by Gitee
parent 5c9ee73fa4
commit 6120aa3ee8
1 changed files with 14 additions and 3 deletions

View File

@ -12,11 +12,22 @@
import pytest
from tools.db import DB
from tools.read_file import ReadFile
@pytest.fixture(scope="session")
def get_db():
"""关于其作用域请移步查看官方文档"""
db = DB()
yield db
db.close()
try:
db = DB()
yield db
finally:
db.close()
@pytest.fixture(params=ReadFile.read_testcase())
def cases(request):
"""用例数据,测试方法参数入参该方法名 cases即可实现同样的参数化
目前来看相较于@pytest.mark.parametrize 更简洁
"""
return request.param