refactor: 优化配置和日志初始化流程

移除RELOAD配置项,改为根据环境变量动态设置
调整banner显示逻辑,确保在日志初始化后执行
将部分错误日志改为警告级别
更新.gitignore,添加缓存目录
重构测试文件,添加健康检查测试
This commit is contained in:
zhangtao
2025-11-26 01:09:35 +08:00
parent c675952875
commit 6ccafb63ef
11 changed files with 40 additions and 24 deletions
+20 -5
View File
@@ -1,7 +1,22 @@
import pytest
"""
注意测试函数是普通的 def,不是 async def。
def test_example():
assert 1 + 1 == 2
还有client的调用也是普通的调用,不是用 await。
if __name__ == "__main__":
pytest.main()
这让你可以直接使用 pytest 而不会遇到麻烦。
"""
from fastapi.testclient import TestClient
from main import create_app
app = create_app()
client = TestClient(app)
def test_check_health():
response = client.get("/")
assert response.status_code == 200
assert response.json() == {"msg": "Healthy"}