精简像素调试图与日志

This commit is contained in:
Your Name committed 2026-06-03 02:11:45 +08:00
1 parent 168ab4e1f8
commit e51d37890a
11 files changed
+663 -297

No files matched your search

@@ -96,6 +96,51 @@ class TestSaveImageModule:
assert callable(save_debug_image)
def test_build_debug_filename_uses_short_english_codes(self):
from douyin.handlers.screenshot_manager.save_image_helpers import build_debug_filename
filename = build_debug_filename(
"pixel_detect",
"lucky_draw_result",
"before_detect",
(290, 1300, 790, 1415),
{
"threshold": 0.8,
"region_size": "500x115",
"ui_version": "v2_0",
"pixel_style": "white",
"text_preview": "我知道了",
},
)
assert filename.endswith(".png")
assert len(filename) <= 120
assert "_px_lottery_pre_" in filename
assert "像素检测" not in filename
assert "抽奖结果" not in filename
assert "检测前" not in filename
def test_cleanup_single_operation_debug_images_keeps_only_pixel_latest(self, tmp_path, monkeypatch):
from douyin.handlers.screenshot_manager.save_image_helpers import (
cleanup_single_operation_debug_images,
)
(tmp_path / "20260603_像素检测_福袋图标_检测成功.png").write_bytes(b"old")
(tmp_path / "20260603_px_pxstage_ov_ok_1.png").write_bytes(b"old")
ocr_file = tmp_path / "20260603_ocr_fdcontent_postocr.png"
ocr_file.write_bytes(b"keep")
monkeypatch.setattr(
"douyin.handlers.screenshot_manager.save_image_helpers.get_debug_captures_dir",
lambda: str(tmp_path),
)
cleanup_single_operation_debug_images("pixel_detect")
assert not (tmp_path / "20260603_像素检测_福袋图标_检测成功.png").exists()
assert not (tmp_path / "20260603_px_pxstage_ov_ok_1.png").exists()
assert ocr_file.exists()
class TestScreenshotManagerSubmodules:
"""screenshot_manager 子模块存在性测试。"""