from __future__ import annotations from types import SimpleNamespace from PIL import Image def test_fudai_detail_debug_overview_saves_one_annotated_image(tmp_path, monkeypatch): from douyin.core import path_config from douyin.fudai.core import fudai_debug_utils screenshot = tmp_path / "screenshot.png" Image.new("RGB", (1080, 2400), "white").save(screenshot) saved = [] def fake_save_debug_image(image, **kwargs): saved.append((image.copy(), kwargs)) return str(tmp_path / "overview.png") monkeypatch.setattr(path_config, "get_screenshot_path", lambda: str(screenshot)) monkeypatch.setattr( "douyin.handlers.douyin_screenshot_manager.save_debug_image", fake_save_debug_image, ) analyser = SimpleNamespace( resolution_ratio_x=1080, resolution_ratio_y=2400, _log_kv=lambda *args, **kwargs: None, ) result = fudai_debug_utils.save_fudai_detail_debug_overview( analyser, [ { "key": "content", "name": "内容", "coords": (300, 1400, 1030, 1515), "enabled": True, }, { "key": "participants", "name": "人数", "coords": (520, 1325, 760, 1415), "enabled": False, }, ], ui_version="v2_0", ocr_enabled={"content"}, task_count=1, task_count_source="v2_pixels", ) assert result assert len(saved) == 1 _image, kwargs = saved[0] assert kwargs["picname"] == "福袋详情综合标注" assert kwargs["step"] == "detail_regions" assert kwargs["annotate"] is False assert kwargs["extra_info"]["ui_version"] == "v2_0"