test: 修复代码检查警告并优化测试用例

1. 为测试代码添加pyrefly忽略注释解决类型检查警告
2. 优化lambda参数命名为通配符符合PEP8规范
3. 增加断言检查任务函数非空并修正参数传递
4. 统一环境变量测试的命名和清理逻辑
This commit is contained in:
2026-06-27 16:26:56 +08:00
parent 87dd010342
commit 7463a60649
4 changed files with 41 additions and 23 deletions
+4 -4
View File
@@ -235,7 +235,7 @@ def test_is_running_windows_found(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(
"subprocess.run",
lambda *a, **kw: MockResult(),
lambda *_, **__: MockResult(),
)
cond = BuiltinConditions.IS_RUNNING("explorer.exe")
assert cond({}) is True
@@ -252,7 +252,7 @@ def test_is_running_windows_not_found(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(
"subprocess.run",
lambda *a, **kw: MockResult(),
lambda *_, **__: MockResult(),
)
cond = BuiltinConditions.IS_RUNNING("explorer.exe")
assert cond({}) is False
@@ -268,7 +268,7 @@ def test_is_running_linux_found(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(
"subprocess.run",
lambda *a, **kw: MockResult(),
lambda *_, **__: MockResult(),
)
cond = BuiltinConditions.IS_RUNNING("nginx")
assert cond({}) is True
@@ -284,7 +284,7 @@ def test_is_running_linux_not_found(monkeypatch: pytest.MonkeyPatch):
monkeypatch.setattr(
"subprocess.run",
lambda *a, **kw: MockResult(),
lambda *_, **__: MockResult(),
)
cond = BuiltinConditions.IS_RUNNING("nonexistent")
assert cond({}) is False