feat(file-check): 增加文件检核 Excel 下载链接解析与展示功能
This commit is contained in:
1 parent
5e7e5a8717
commit
f21216f81e
21 files changed
+885
-125
No files matched your search
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
import importlib.util
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
@@ -69,9 +70,10 @@ def test_env_strips_wrapping_quotes(monkeypatch):
|
||||
|
||||
|
||||
def test_configure_file_logging_tees_stdout_and_stderr(monkeypatch, tmp_path, capsys):
|
||||
"""配置 FREIGHT_RPA_LOG_FILE 后,stdout/stderr 应同时写入日志文件。"""
|
||||
"""配置 FREIGHT_RPA_LOG_FILE 后,stdout/stderr 应同时写入日志文件并带行首时间戳。"""
|
||||
worker = _load_freight_rpa_worker()
|
||||
log_path = tmp_path / "logs" / "worker.log"
|
||||
timestamp_pattern = re.compile(r"^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} ")
|
||||
|
||||
monkeypatch.setenv("FREIGHT_RPA_LOG_FILE", str(log_path))
|
||||
original_stdout = sys.stdout
|
||||
@@ -91,10 +93,16 @@ def test_configure_file_logging_tees_stdout_and_stderr(monkeypatch, tmp_path, ca
|
||||
assert resolved == log_path
|
||||
assert "hello stdout" in captured.out
|
||||
assert "hello stderr" in captured.err
|
||||
assert timestamp_pattern.search(captured.out)
|
||||
assert timestamp_pattern.search(captured.err)
|
||||
text = log_path.read_text(encoding="utf-8")
|
||||
assert "[logging] tee enabled" in text
|
||||
assert "hello stdout" in text
|
||||
assert "hello stderr" in text
|
||||
# 断言:每行非空日志均带 YYYY-MM-DD HH:MM:SS 前缀,便于长批次排障。
|
||||
for line in text.splitlines():
|
||||
if line.strip():
|
||||
assert timestamp_pattern.match(line)
|
||||
|
||||
|
||||
def test_rotate_log_file_when_size_reaches_limit(monkeypatch, tmp_path):
|
||||
|
||||
Reference in new issue
Block a user