精简像素调试图与日志

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

+48
View File
@@ -158,6 +158,54 @@ class TestPixelStage:
assert hasattr(stage_mod, "detect_attend_button_red_area")
assert hasattr(stage_mod, "detect_fansclub_join_red_area")
def test_read_pixel_stage_saves_single_overview_debug_image(self, tmp_path, monkeypatch):
from douyin.detection.pixel.stage import read_pixel_stage_state_from_screenshot
img_path = tmp_path / "screen.png"
Image.new("RGB", (1080, 2400), (20, 20, 20)).save(img_path)
debug_dir = tmp_path / "debug"
debug_dir.mkdir()
(debug_dir / "20260603_像素检测_抽奖结果_检测前.png").write_bytes(b"old")
(debug_dir / "20260603_px_attend_pre.png").write_bytes(b"old")
calls = []
def fake_save_debug_image(image, **kwargs):
calls.append(kwargs)
return str(debug_dir / "20260603_px_pxstage_ov_ok_0.png")
monkeypatch.setattr(
"douyin.handlers.screenshot_manager.save_image_helpers.is_debug_captures_enabled",
lambda: True,
)
monkeypatch.setattr(
"douyin.handlers.screenshot_manager.paths.get_debug_captures_dir",
lambda: str(debug_dir),
)
monkeypatch.setattr(
"douyin.handlers.douyin_screenshot_manager.save_debug_image",
fake_save_debug_image,
)
read_pixel_stage_state_from_screenshot(
str(img_path),
return_details=True,
analyser=SimpleNamespace(
fudai_detail_ui_mode="v2_0",
pixel_detect_coupon_popup_enabled=False,
pixel_detect_shopping_redpacket_enabled=False,
pixel_detect_fudai_detail_enabled=False,
),
)
assert len(calls) == 1
assert calls[0]["operation_type"] == "pixel_detect"
assert calls[0]["picname"] == "pixel_stage"
assert calls[0]["step"] == "overview"
assert calls[0]["annotate"] is False
assert not (debug_dir / "20260603_像素检测_抽奖结果_检测前.png").exists()
assert not (debug_dir / "20260603_px_attend_pre.png").exists()
class TestPixelCommon:
"""pixel/_common 模块测试。"""