Skip to content

Commit 4181360

Browse files
fix(test): OPD CLI help 测试改为命令模型断言,消除渲染宽度依赖
- --teacher-model 存在性改由 typer get_command 命令模型校验(不再断言渲染文本) - rich 在不同终端宽度/平台(Linux CI 80 列)会截断或连字符换行 option 名,导致误报 - help 文档散文断言保留,增加 ANSI 剥离
1 parent a982b18 commit 4181360

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎tests/unit/test_agentic_rl_cli_opd.py‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""Minimal CLI coverage for teacher_model."""
33

4+
import re
45
from unittest.mock import patch
56

67
import pytest
8+
from typer.main import get_command
79
from typer.testing import CliRunner
810

911
from dashscope.cli.agentic_rl import _run_workflow_async, app
@@ -12,10 +14,17 @@
1214

1315
def test_run_help_explains_conditional_function_requirements():
1416
result = CliRunner().invoke(app, ["run", "--help"])
15-
help_text = " ".join(result.output.split())
16-
1717
assert result.exit_code == 0
18-
assert "--teacher-model" in help_text
18+
19+
# 参数存在性走 typer 命令模型校验:渲染文本在不同终端宽度/平台下会被
20+
# rich 截断或连字符换行(CI Linux 曾因此误报 --teacher-model 缺失),
21+
# 不断言渲染后的 help 文本里出现完整 option 名。
22+
run_cmd = get_command(app).commands["run"]
23+
assert "teacher_model" in {param.name for param in run_cmd.params}
24+
25+
# help 文档仍须说明 OPD 的条件化函数要求;剥离 ANSI 后按空白归一,
26+
# 只断言散文式描述(按空格折行,归一化后稳定)。
27+
help_text = " ".join(re.sub(r"\x1b\[[0-9;]*m", "", result.output).split())
1928
assert (
2029
"1. Configuration-driven: Use -c/--config to specify a YAML file"
2130
in help_text

0 commit comments

Comments
 (0)