Test loading PDF from BytesIO with lazy=True.
()
| 695 | |
| 696 | |
| 697 | def 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 | |
| 725 | def test_load_from_bytesio_eager(): |
nothing calls this directly
no test coverage detected