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