first commit
This commit is contained in:
34
tests/conftest.py
Normal file
34
tests/conftest.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""
|
||||
pytest配置文件
|
||||
定义测试fixtures
|
||||
"""
|
||||
import pytest
|
||||
from src.your_app import create_app, db
|
||||
from config import TestingConfig
|
||||
|
||||
@pytest.fixture
|
||||
def app():
|
||||
"""
|
||||
创建测试应用实例
|
||||
"""
|
||||
app = create_app(TestingConfig)
|
||||
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
yield app
|
||||
db.drop_all()
|
||||
|
||||
@pytest.fixture
|
||||
def client(app):
|
||||
"""
|
||||
创建测试客户端
|
||||
"""
|
||||
return app.test_client()
|
||||
|
||||
@pytest.fixture
|
||||
def runner(app):
|
||||
"""
|
||||
创建CLI测试运行器
|
||||
"""
|
||||
return app.test_cli_runner()
|
||||
|
||||
Reference in New Issue
Block a user