Skip to content

Commit

Permalink
添加单元测试
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwenxu1 committed Jan 1, 2025
1 parent 819c1a5 commit d12ff9b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 1 addition & 2 deletions tests/test_logo_recog.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_pred_rcnn_image_notwith_alpha_channel():
mock_image.shape = (100, 100, 3) # 包含 alpha 通道

with patch('logo_recog.cv2.imread', return_value=mock_image) as mock_imread:
# 模拟 predictor 的输出
# 模拟 predictor 的输出
mock_instances = MagicMock()
mock_instances.pred_classes = MagicMock()
mock_instances.pred_classes.__getitem__.return_value = MagicMock()
Expand Down Expand Up @@ -214,4 +214,3 @@ def test_vis_pred_boxes_not_tensor_or_numpy(dummy_image):
with pytest.raises(AttributeError):
# 因为函数尝试对列表调用 .numpy(),应引发 AttributeError
vis(img_path, invalid_pred_boxes)

1 change: 0 additions & 1 deletion tests/test_phishpedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ def test_test_orig_phishpedia_no_logo(mock_check_inconsistency, mock_vis, mock_p
mock_pred_rcnn.assert_called_once_with(im="path/to/shot.png", predictor=phishpedia_wrapper.ELE_MODEL)
mock_vis.assert_called_once_with("path/to/shot.png", None)
mock_check_inconsistency.assert_not_called()

0 comments on commit d12ff9b

Please sign in to comment.