diff --git a/tests/assets/test_latex.png b/tests/assets/test_latex.png new file mode 100644 index 0000000..c095eb3 Binary files /dev/null and b/tests/assets/test_latex.png differ diff --git a/tests/conftest.py b/tests/conftest.py index f7a243c..c0cff37 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,3 +79,10 @@ def test_image_tall(): font_size=24, ) return image + +@pytest.fixture() +def test_image_latex(): + assets_dir = os.path.join(os.path.dirname(__file__), "assets") + img_path = os.path.join(assets_dir, "test_latex.png") + image = Image.open(img_path).convert("RGB") + return image \ No newline at end of file diff --git a/tests/test_latex_ocr.py b/tests/test_latex_ocr.py index a35919a..727f029 100644 --- a/tests/test_latex_ocr.py +++ b/tests/test_latex_ocr.py @@ -6,13 +6,10 @@ from surya.common.surya.schema import TaskNames from surya.recognition import OCRResult -def test_latex_ocr(recognition_predictor): - img = Image.new("RGB", (200, 100), color="white") - draw = ImageDraw.Draw(img) - draw.text((10, 10), "E = mc2", fill="black", font_size=48) - +def test_latex_ocr(recognition_predictor, test_image_latex): + width, height = test_image_latex.size results: List[OCRResult] = recognition_predictor( - [img], [TaskNames.block_without_boxes], bboxes=[[[0, 0, 200, 100]]] + [test_image_latex], [TaskNames.block_without_boxes], bboxes=[[[0, 0, width, height]]] ) text = results[0].text_lines[0].text assert len(results) == 1