test: 修复代码检查警告并优化测试用例
1. 为测试代码添加pyrefly忽略注释解决类型检查警告 2. 优化lambda参数命名为通配符符合PEP8规范 3. 增加断言检查任务函数非空并修正参数传递 4. 统一环境变量测试的命名和清理逻辑
This commit is contained in:
@@ -127,6 +127,7 @@ def test_should_execute_condition_exception_returns_false() -> None:
|
||||
spec = TaskSpec("a", _fn, conditions=(bad_condition,))
|
||||
should_run, reason = spec.should_execute({})
|
||||
assert should_run is False
|
||||
# pyrefly: ignore [not-iterable]
|
||||
assert "匿名条件(执行错误)" in reason
|
||||
|
||||
|
||||
@@ -135,6 +136,7 @@ def test_should_execute_condition_lambda_name() -> None:
|
||||
spec = TaskSpec("a", _fn, conditions=(lambda _ctx: False,))
|
||||
should_run, reason = spec.should_execute({})
|
||||
assert should_run is False
|
||||
# pyrefly: ignore [not-iterable]
|
||||
assert "<lambda>" in reason
|
||||
|
||||
|
||||
@@ -143,6 +145,7 @@ def test_should_execute_skip_if_missing_cmd_not_found() -> None:
|
||||
spec = TaskSpec("a", cmd=["nonexistent_cmd_xyz"], skip_if_missing=True)
|
||||
should_run, reason = spec.should_execute({})
|
||||
assert should_run is False
|
||||
# pyrefly: ignore [not-iterable]
|
||||
assert "命令不存在" in reason
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user