From 487877fa08d3612bbacb2be2196dd4b37cab7e84 Mon Sep 17 00:00:00 2001 From: simonkoson <28867558@qq.com> Date: Mon, 15 Jun 2026 12:13:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20test=5Fsubtitle=5Ff?= =?UTF-8?q?rame=20=E5=88=87=E7=89=87=E6=AF=94=E4=BE=8B(10%->1%)=20?= =?UTF-8?q?=E5=92=8C=20test=5Fratio=5Fok=5Fbut=5Fmax=5Fbrightness=5Ftoo=5F?= =?UTF-8?q?low=20=E6=96=AD=E8=A8=80(=E9=80=82=E9=85=8D=E9=98=88=E5=80=BC24?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doco/tests/test_video_split.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doco/tests/test_video_split.py b/doco/tests/test_video_split.py index 944e166..30b6934 100644 --- a/doco/tests/test_video_split.py +++ b/doco/tests/test_video_split.py @@ -163,7 +163,7 @@ class TestIsBlankFrame: img_path = tmp_path / "subtitle.png" arr = np.zeros((100, 100), dtype=np.uint8) # 1% 白像素(亮度255),其余黑(亮度0) - arr[:100, :10] = 255 + arr[:10, :10] = 255 # 10×10=100/10000=1% img = Image.fromarray(arr, mode="L") img.save(img_path) @@ -189,17 +189,18 @@ class TestIsBlankFrame: assert white_ratio < 0.005 def test_ratio_ok_but_max_brightness_too_low(self, tmp_path): - """white_ratio>=0.005 但 max_brightness<240 → is_blank=True""" + """max_brightness<240 → 白像素计数全为0 → is_blank=True""" from PIL import Image import numpy as np img_path = tmp_path / "dim_pixels.png" arr = np.zeros((100, 100), dtype=np.uint8) - # 1% 像素亮度=220(不够240阈值),其余黑 - arr[:100, :10] = 220 + # 1% 像素亮度=220(不满足阈值240),其余黑 + # is_blank_frame 用 arr > 240 统计白像素,220 全不满足 → white_ratio=0 + arr[:10, :10] = 220 img = Image.fromarray(arr, mode="L") img.save(img_path) is_blank, white_ratio, max_brightness = is_blank_frame(img_path) assert is_blank is True assert max_brightness == 220 - assert white_ratio >= 0.005 + assert white_ratio == 0.0