forked from DxvLwRYF/apiAutoTest
添加初始化用例操作
This commit is contained in:
parent
5c9ee73fa4
commit
6120aa3ee8
|
@ -12,11 +12,22 @@
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from tools.db import DB
|
from tools.db import DB
|
||||||
|
from tools.read_file import ReadFile
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session")
|
@pytest.fixture(scope="session")
|
||||||
def get_db():
|
def get_db():
|
||||||
"""关于其作用域请移步查看官方文档"""
|
"""关于其作用域请移步查看官方文档"""
|
||||||
|
try:
|
||||||
db = DB()
|
db = DB()
|
||||||
yield db
|
yield db
|
||||||
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(params=ReadFile.read_testcase())
|
||||||
|
def cases(request):
|
||||||
|
"""用例数据,测试方法参数入参该方法名 cases即可,实现同样的参数化
|
||||||
|
目前来看相较于@pytest.mark.parametrize 更简洁。
|
||||||
|
"""
|
||||||
|
return request.param
|
||||||
|
|
Loading…
Reference in New Issue