本地跑:tools/run_tests.py + README「本地怎么跑」(239 测试)
This commit is contained in:
@@ -314,3 +314,48 @@ data/
|
|||||||
`deploy/` 里有三种跑法(Docker Compose / systemd / 本机),以及 Caddy 反代、备份脚本、上线检查清单。先看 [deploy/README.md](deploy/README.md)。
|
`deploy/` 里有三种跑法(Docker Compose / systemd / 本机),以及 Caddy 反代、备份脚本、上线检查清单。先看 [deploy/README.md](deploy/README.md)。
|
||||||
|
|
||||||
注意两条平台限制:Linux 服务器上没有 Windows OCR,拍照识题要配 `OCR_HTTP_URL`;手机号登录的短信服务商还没接(现在验证码直接回显,只适合本机)。
|
注意两条平台限制:Linux 服务器上没有 Windows OCR,拍照识题要配 `OCR_HTTP_URL`;手机号登录的短信服务商还没接(现在验证码直接回显,只适合本机)。
|
||||||
|
|
||||||
|
## 本地怎么跑(三步)
|
||||||
|
|
||||||
|
### 一、起后端
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
cd D:\gitee\errortopic
|
||||||
|
python -m backend.app --port 8000 # 只给本机用
|
||||||
|
python -m backend.app --host 0.0.0.0 --port 8000 # 手机也想连(同一个 Wi-Fi)
|
||||||
|
```
|
||||||
|
|
||||||
|
启动后:
|
||||||
|
|
||||||
|
- 工作台 <http://127.0.0.1:8000/workbench>
|
||||||
|
- 接口控制台 <http://127.0.0.1:8000/>(列出 60 条路由)
|
||||||
|
- 接口文档 <http://127.0.0.1:8000/docs>
|
||||||
|
|
||||||
|
### 二、登录(dev 模式不用微信)
|
||||||
|
|
||||||
|
打开工作台会显示 8 位登录码。`wx_mode` 是 `dev` 时,码下面有一个
|
||||||
|
**「模拟确认」**按钮——点它等于手机扫码确认,直接进工作台,数据写
|
||||||
|
`data/app.db`。
|
||||||
|
|
||||||
|
不想连后端也能看界面:直接双击打开 `prototype/workbench/index.html`,
|
||||||
|
点「先看演示」,用的是内置演示数据(不含拍照入库,那个必须后端)。
|
||||||
|
|
||||||
|
### 三、手机上试
|
||||||
|
|
||||||
|
同一 Wi-Fi 下用手机浏览器打开 `http://<电脑局域网 IP>:8000/workbench`
|
||||||
|
(Windows 上用 `ipconfig` 看 WLAN 的 IPv4)。底部会变成 6 个 tab 的导航,
|
||||||
|
今日训练 / 错题本 / 周报三屏都能用。
|
||||||
|
|
||||||
|
## 本地怎么验
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
python tools/run_tests.py # 239 个单测
|
||||||
|
python tests\smoke_http.py # 41 项接口冒烟
|
||||||
|
python tests\smoke_manual.py # 22 项手工链路
|
||||||
|
python tests\smoke_login.py # 21 项登录
|
||||||
|
python tests\smoke_junior.py # 29 项初中版
|
||||||
|
```
|
||||||
|
|
||||||
|
拍照入库会真调腾讯云切题(**一张照片 1 次调用**,勾到口算卡再裁一次,命中
|
||||||
|
缓存就不花钱)。本月用量看 `data/ocr_usage.json`,免费额度 1000 次/月,
|
||||||
|
`OCR_MONTHLY_LIMIT` 到顶会自动停手。
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"ok": true, "data": {"QuestionInfo": [{"Angle": 0, "Height": 300, "ImageBase64": "", "OrgHeight": 300, "OrgWidth": 900, "ResultList": null, "Width": 900}], "RequestId": "a359c898-8b7e-43b6-b214-495e94678f17"}, "request_id": "a359c898-8b7e-43b6-b214-495e94678f17"}
|
{"ok": true, "data": {"QuestionInfo": [{"Angle": 0, "Height": 300, "ImageBase64": "", "OrgHeight": 300, "OrgWidth": 900, "ResultList": null, "Width": 900}], "RequestId": "8c038348-eb95-4a92-a4fd-3b19e7148968"}, "request_id": "8c038348-eb95-4a92-a4fd-3b19e7148968"}
|
||||||
+1
-1
@@ -1 +1 @@
|
|||||||
{"2026-11": 113}
|
{"2026-11": 137}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 147 KiB |
@@ -0,0 +1,33 @@
|
|||||||
|
"""一条命令跑全部单测:python tools/run_tests.py
|
||||||
|
|
||||||
|
为什么不用 `unittest discover`:`tests/` 不是包(没有 `__init__.py`,故意的,
|
||||||
|
省得 import 时踩相对导入),`discover -s tests -t .` 会直接报
|
||||||
|
`Start directory is not importable`。这里按文件名显式列出,稳。
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import glob
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import unittest
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parent.parent
|
||||||
|
sys.path.insert(0, str(ROOT))
|
||||||
|
os.chdir(ROOT)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
mods = ["tests." + os.path.basename(p)[:-3]
|
||||||
|
for p in sorted(glob.glob("tests/test_*.py"))]
|
||||||
|
if not mods:
|
||||||
|
print("没找到 tests/test_*.py")
|
||||||
|
return 1
|
||||||
|
suite = unittest.defaultTestLoader.loadTestsFromNames(mods)
|
||||||
|
res = unittest.TextTestRunner(verbosity=1).run(suite)
|
||||||
|
return 0 if res.wasSuccessful() else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
raise SystemExit(main())
|
||||||
Reference in New Issue
Block a user