mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-24 23:54:14 +00:00
Fix test_parser_with_table
This commit is contained in:
parent
be47099747
commit
898e2a5b51
@ -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 ""
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user