test: add pytest suite — CLI smoke + config/templates/md_to_pdf units
- tests/conftest.py redirects MYTOOLKIT_HOME to a temp dir before imports so the module-level Config singleton never touches the real ~/.mytoolkit - CLI smoke: every registered command answers --help with exit code 0 - unit tests: Config get/set/migrate, templates_registry override/fallback, md_to_pdf pure helpers (pandoc-dependent cases skipif-guarded) - pyproject: dev dependency group (pytest) + pytest config; Makefile: make test
This commit is contained in:
@@ -135,6 +135,18 @@ mytoolkit init journal springer mydir
|
||||
uv sync
|
||||
```
|
||||
|
||||
### 测试
|
||||
|
||||
```bash
|
||||
make test # 或 uv run pytest tests/ -q
|
||||
```
|
||||
|
||||
- 第一层:CLI 冒烟(`tests/test_cli_smoke.py`)——所有命令 `--help` 必须退出码为 0,覆盖 import 链断裂/注册丢失。
|
||||
- 第二层:纯逻辑单测(`config` / `templates_registry` / `md_to_pdf` 纯函数)。
|
||||
- 不测外部 API(voice/image)与重型二进制真实调用;pandoc 相关用例用 `skipif` 保护。
|
||||
- `tests/conftest.py` 在 import 前把 `MYTOOLKIT_HOME` 指向临时目录,测试永不触碰真实 `~/.mytoolkit`。
|
||||
- 新增命令时必须保证冒烟测试通过;新纯函数优先补单测。
|
||||
|
||||
---
|
||||
|
||||
## 6. 命名规范
|
||||
|
||||
Reference in New Issue
Block a user