diff --git a/tests/test_paddleocr_api.py b/tests/test_paddleocr_api.py index 873f262732..9c23f27296 100644 --- a/tests/test_paddleocr_api.py +++ b/tests/test_paddleocr_api.py @@ -5,7 +5,7 @@ @pytest.fixture def ocr(): - return PaddleOCR(lang="en") + return PaddleOCR(lang="ch") @pytest.fixture @@ -13,25 +13,25 @@ def img(): return cv2.imread("doc/imgs/1.jpg") -def test_ocr_with_detection_and_recognition(ocr, img): - result = ocr.ocr(img, det=True, rec=True) - assert result is not None - assert isinstance(result, list) - - -def test_ocr_with_detection_only(ocr, img): - result = ocr.ocr(img, det=True, rec=False) +@pytest.mark.parametrize( + "det, rec", [(True, True), (True, False), (False, True), (False, False)] +) +def test_ocr_det_rec_api(ocr, img, det, rec): + result = ocr.ocr(img, det=det, rec=rec) assert result is not None assert isinstance(result, list) -def test_ocr_with_recognition_only(ocr, img): - result = ocr.ocr(img, det=False, rec=True) +def test_ocr_fp16(): + ocr = PaddleOCR(lang="ch", use_angle_cls=True, precision=True) + img = cv2.imread("doc/imgs/1.jpg") + result = ocr.ocr(img, det=True, rec=True) assert result is not None assert isinstance(result, list) -def test_ocr_without_detection_and_recognition(ocr, img): - result = ocr.ocr(img, det=False, rec=False) - assert result is not None - assert isinstance(result, list) +def test_ocr_with_none_image(): + ocr = PaddleOCR(lang="ch") + img = None + with pytest.raises(AssertionError): + ocr.ocr(img, det=True, rec=True)