diff --git a/packages/shared/cover_frame_scorer.py b/packages/shared/cover_frame_scorer.py index fe7c000e4..80de9c350 100644 --- a/packages/shared/cover_frame_scorer.py +++ b/packages/shared/cover_frame_scorer.py @@ -41,6 +41,7 @@ def score_frame(frame: "np.ndarray") -> float: try: import cv2 import numpy as np + # 确保 cv2 和 numpy 是真实的模块,不是 mock 对象 # MagicMock 会有所有属性,但调用结果不是真实数值类型 if not hasattr(cv2, "Laplacian") or not hasattr(np, "ndarray"): diff --git a/tests/unit/test_cover_frame_scorer.py b/tests/unit/test_cover_frame_scorer.py index 786babd1c..7e2fe0d9c 100644 --- a/tests/unit/test_cover_frame_scorer.py +++ b/tests/unit/test_cover_frame_scorer.py @@ -21,7 +21,7 @@ def _cv2_available() -> bool: try: import cv2 import numpy as np - + if not hasattr(cv2, "Laplacian") or not inspect.isroutine(cv2.Laplacian): return False if "mock" in str(type(cv2.Laplacian)).lower():