mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-27 08:58:48 +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,
|
mode: str,
|
||||||
extract_tables: str,
|
extract_tables: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
from PIL.Image import Image
|
|
||||||
|
|
||||||
from langchain_community.document_loaders.parsers.images import BaseImageBlobParser
|
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.
|
"""Standard tests to verify that the given parser works.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
@ -291,17 +301,3 @@ def test_parser_with_table(
|
|||||||
assert len(tables) >= 1
|
assert len(tables) >= 1
|
||||||
else:
|
else:
|
||||||
assert not len(tables)
|
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