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

Function test_get_page_individually

tests/test_parse.py:782–803  ·  view source on GitHub ↗

Test accessing individual pages without iterating all pages.

()

Source from the content-addressed store, hash-verified

780
781
782def test_get_page_individually():
783 """Test accessing individual pages without iterating all pages."""
784 filename = "tests/data/regression/table_of_contents_01.pdf"
785
786 parser = DoclingPdfParser(loglevel="fatal")
787 pdf_doc = parser.load(path_or_stream=filename, lazy=True)
788
789 num_pages = pdf_doc.number_of_pages()
790 assert num_pages > 2, "Test needs PDF with multiple pages"
791
792 # Access page 2 directly (should not load other pages)
793 page_2 = pdf_doc.get_page(2)
794 assert any(k[0] == 2 for k in pdf_doc._pages)
795 assert not any(k[0] == 1 for k in pdf_doc._pages) # Page 1 should not be loaded
796 assert not any(k[0] == 3 for k in pdf_doc._pages) # Page 3 should not be loaded
797
798 # Access page 1
799 page_1 = pdf_doc.get_page(1)
800 assert any(k[0] == 1 for k in pdf_doc._pages)
801
802 # Verify pages are different
803 assert page_1 != page_2
804
805
806def test_unload_individual_pages():

Callers

nothing calls this directly

Calls 4

loadMethod · 0.95
DoclingPdfParserClass · 0.90
number_of_pagesMethod · 0.45
get_pageMethod · 0.45

Tested by

no test coverage detected