refactor(emlmanager): 重构EML解析逻辑,提取公共方法并优化字符编码处理
1. 拆分邮件解析为多部分/单部分处理函数,抽离正文提取、日期解析逻辑 2. 完善字符编码检测与 fallback 处理,使用replace模式避免解码失败崩溃 3. 统一使用配置的最大正文长度限制,添加详细日志记录 4. 修复原代码中解码异常未妥善处理的问题 5. 优化测试用例,使用tmp_path替代固定临时目录提升测试稳定性
This commit is contained in:
@@ -60,9 +60,9 @@ class TestSetRustMirror:
|
||||
assert cargo_dir.exists()
|
||||
assert cargo_dir.is_dir()
|
||||
|
||||
def test_set_rust_mirror_prints_message(self, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
def test_set_rust_mirror_prints_message(self, tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
"""Should print mirror name."""
|
||||
with patch.object(Path, "home", return_value=Path("/tmp")):
|
||||
with patch.object(Path, "home", return_value=tmp_path):
|
||||
envrs.set_rust_mirror("aliyun")
|
||||
captured = capsys.readouterr()
|
||||
assert "已设置 Rust 镜像源: aliyun" in captured.out
|
||||
|
||||
Reference in New Issue
Block a user