Skip to content

测试RestAPI

运行测试

先启动服务

shell
python app.py

运行测试

shell
python -m unittest test_api.py
shell
case4_test_client % python -m unittest test_api.py
./flask-web/flask-env/lib/python3.8/site-packages/flask_sqlalchemy/query.py:30: LegacyAPIWarning: The Query.get() method is considered legacy as of the 1.x series of SQLAlchemy and becomes a legacy construct in 2.0. The method is now available as Session.get() (deprecated since: 2.0) (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
  rv = self.get(ident)
.....
----------------------------------------------------------------------
Ran 6 tests in 0.045s

OK

参看代码

https://gitee.com/PatrickW/flask-web/blob/master/src/case4_test_client/test_api.py