From 364e12b9ff6989270a96c5de4f3afc3f26522102 Mon Sep 17 00:00:00 2001 From: bosd Date: Mon, 14 Oct 2024 19:38:39 +0200 Subject: [PATCH] TODO Mock pdfium unavailable for lattice test --- tests/test_lattice.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/test_lattice.py b/tests/test_lattice.py index 667243a1..e7ef59f3 100644 --- a/tests/test_lattice.py +++ b/tests/test_lattice.py @@ -1,4 +1,6 @@ import os +import sys +from unittest import mock import pandas as pd from pandas.testing import assert_frame_equal @@ -49,6 +51,22 @@ def test_lattice_table_regions(testdir): assert_frame_equal(df, tables[0].df) +def test_lattice_table_regions_mock_pdfium(testdir): # added this test for behaviour + # This test should fail, but it does not + df = pd.DataFrame(data_lattice_table_regions) + + filename = os.path.join(testdir, "table_region.pdf") + with mock.patch.dict(sys.modules, {"pypdfium2": None}): + tables = camelot.read_pdf( + filename, + flavor="lattice", + backend="pdfium", + use_fallback=False, + table_regions=["170,370,560,270"], + ) + assert_frame_equal(df, tables[0].df) + + def test_lattice_table_areas(testdir): df = pd.DataFrame(data_lattice_table_areas)