Skip to content

Commit

Permalink
update ut
Browse files Browse the repository at this point in the history
  • Loading branch information
GreatV committed May 8, 2024
1 parent eb402da commit 28a4afa
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/test_paddleocr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,33 @@

@pytest.fixture
def ocr():
return PaddleOCR(lang="en")
return PaddleOCR(lang="ch")


@pytest.fixture
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)

0 comments on commit 28a4afa

Please sign in to comment.