test(cli): 为文件写入错误测试添加root权限跳过逻辑
CI / Lint, Typecheck & Test (push) Has been cancelled

This commit is contained in:
2026-07-04 10:22:35 +08:00
parent 37ac4b8025
commit 85793ff9d5
+4
View File
@@ -2,6 +2,7 @@
from __future__ import annotations
import os
from pathlib import Path
from unittest.mock import patch
@@ -161,6 +162,9 @@ dependencies = ["lib >= 2.0.0", "other >= 3.0.0"]
def test_file_write_error(self, tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
"""Should handle file write errors."""
if os.geteuid() == 0:
pytest.skip("测试在 root 权限下不适用")
# 在只读目录中创建文件(这个测试在某些系统上可能不适用)
test_file = tmp_path / "readonly.toml"
test_file.write_text('version = "1.0.0"', encoding="utf-8")