我正在尝试消除 Flask-SQLAlchemy 的弃用警告,如果与修改跟踪一起使用会增加开销:
config.py 文件:
class BaseConfig:
DEBUG = False
TESTING = False
SQLALCHEMY_DATABASE_URI = ''
SQLALCHEMY_TRACK_MODIFICATIONS = False
class TestingConfig(BaseConfig):
TESTING = True
测试文件:
from flask_testing import TestCase
from project.config import TestingConfig
from project.models import User
from project import create_app
from project import db
import unittest
app = create_app()
class TestDBsetup(TestCase):
def create_app(self):
app.config.from_object(TestingConfig)
return app
def setUp(self):
db.create_all()
def tearDown(self):
db.session.remove()
db.drop_all()
if __name__ == '__main__':
unittest.main()
我还是很有名的FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
我怎样才能正确地使其静音?