Fix test_parser_with_table

This commit is contained in:
Philippe Prados 2025-02-26 13:49:46 +01:00
parent be47099747
commit 898e2a5b51

View File

@ -247,11 +247,21 @@ def test_parser_with_table(
mode: str,
extract_tables: str,
) -> None:
from PIL.Image import Image
from langchain_community.document_loaders.parsers.images import BaseImageBlobParser
def _std_assert_with_parser(parser: BaseBlobParser) -> None:
parser_class = getattr(pdf_parsers, parser_factory)
parser = parser_class(
mode=mode,
extract_tables=extract_tables,
images_parser=EmptyImageBlobParser(),
**params,
)
_std_assert_table_with_parser(extract_tables, parser)
def _std_assert_table_with_parser(extract_tables: str, parser: BaseBlobParser) -> None:
"""Standard tests to verify that the given parser works.
Args:
@ -291,17 +301,3 @@ def test_parser_with_table(
assert len(tables) >= 1
else:
assert not len(tables)
class EmptyImageBlobParser(BaseImageBlobParser):
def _analyze_image(self, img: Image) -> str:
return "![image](.)"
parser_class = getattr(pdf_parsers, parser_factory)
parser = parser_class(
mode=mode,
extract_tables=extract_tables,
images_parser=EmptyImageBlobParser(),
**params,
)
_std_assert_with_parser(parser)