refactor(tests): 重构测试代码并优化ruff检查规则

1.  在pyproject.toml中为测试文件添加ARG001和ARG002规则忽略
2.  重构多个CLI测试文件,移除冗余的mock断言、导入顺序调整
3.  统一测试用例的帮助信息输出逻辑,移除SystemExit捕获,简化测试流程
4.  拆分合并冗余的测试类,按功能细化测试用例
5.  移除测试代码中多余的注释和pytest导入
This commit is contained in:
2026-06-22 12:18:10 +08:00
parent d4a1a5c2de
commit 413ab40044
13 changed files with 616 additions and 953 deletions
+3 -3
View File
@@ -80,10 +80,10 @@ class TestMain:
assert mock_run.called
def test_main_with_no_args_shows_help(self) -> None:
"""main() with no args should show help and exit."""
with patch("sys.argv", ["envpy"]), pytest.raises(SystemExit) as exc_info:
"""main() with no args should show help and return."""
with patch("sys.argv", ["envpy"]):
envpy.main()
assert exc_info.value.code == 2
# Should print help and return
def test_main_invalid_mirror_shows_error(self) -> None:
"""main() with invalid mirror should show error."""