MCPcopy Create free account
hub / github.com/docling-project/docling-parse / test_load_from_bytesio_lazy

Function test_load_from_bytesio_lazy

tests/test_parse.py:697–722  ·  view source on GitHub ↗

Test loading PDF from BytesIO with lazy=True.

()

Source from the content-addressed store, hash-verified

695
696
697def test_load_from_bytesio_lazy():
698 """Test loading PDF from BytesIO with lazy=True."""
699 filename = "tests/data/regression/table_of_contents_01.pdf"
700
701 # Read file into BytesIO
702 with open(filename, "rb") as file:
703 file_content = file.read()
704 bytes_io = BytesIO(file_content)
705
706 parser = DoclingPdfParser(loglevel="fatal")
707
708 # Load from BytesIO
709 pdf_doc_bytesio = parser.load(path_or_stream=bytes_io, lazy=True)
710
711 # Load from path for comparison
712 pdf_doc_path = parser.load(path_or_stream=filename, lazy=True)
713
714 # Both should have same number of pages
715 assert pdf_doc_bytesio.number_of_pages() == pdf_doc_path.number_of_pages()
716
717 # Load all pages and compare
718 pdf_doc_bytesio.load_all_pages()
719 pdf_doc_path.load_all_pages()
720
721 # Pages should be identical
722 assert pdf_doc_bytesio._pages == pdf_doc_path._pages
723
724
725def test_load_from_bytesio_eager():

Callers

nothing calls this directly

Calls 4

loadMethod · 0.95
DoclingPdfParserClass · 0.90
load_all_pagesMethod · 0.80
number_of_pagesMethod · 0.45

Tested by

no test coverage detected