diff --git a/tests/helpers/test_opener.py b/tests/helpers/test_opener.py index 8f02e5bd8..3459b6513 100644 --- a/tests/helpers/test_opener.py +++ b/tests/helpers/test_opener.py @@ -202,7 +202,7 @@ def test_open_invalid(): def test_object_hierarchy(): - pdf = pdfium.PdfDocument(TestFiles.empty) + pdf = pdfium.PdfDocument(TestFiles.images) assert isinstance(pdf, pdfium.PdfDocument) assert isinstance(pdf.raw, pdfium.FPDF_DOCUMENT) @@ -211,6 +211,12 @@ def test_object_hierarchy(): assert isinstance(page.raw, pdfium.FPDF_PAGE) assert page.pdf is pdf + pageobj = next(page.get_objects()) + assert isinstance(pageobj, pdfium.PdfPageObject) + assert isinstance(pageobj.raw, pdfium.FPDF_PAGEOBJECT) + assert isinstance(pageobj.type, int) + assert pageobj.page is page + textpage = page.get_textpage() assert isinstance(textpage, pdfium.PdfTextPage) assert isinstance(textpage.raw, pdfium.FPDF_TEXTPAGE) diff --git a/tests/helpers/test_page.py b/tests/helpers/test_page.py index e0371b3b4..1488071fd 100644 --- a/tests/helpers/test_page.py +++ b/tests/helpers/test_page.py @@ -3,6 +3,7 @@ import pytest import pypdfium2 as pdfium +from pypdfium2._helpers._utils import ObjtypeToName from ..conftest import TestFiles @@ -52,7 +53,12 @@ def test_pageobjects(): pdf = pdfium.PdfDocument(TestFiles.images) page = pdf.get_page(0) - images = [obj for obj in page.get_objects() if obj.type == pdfium.FPDF_PAGEOBJ_IMAGE] + images = [] + for obj in page.get_objects(): + assert obj.type in ObjtypeToName.keys() + if obj.type == pdfium.FPDF_PAGEOBJ_IMAGE: + assert obj.level == 0 + images.append(obj) assert len(images) == 3 positions = [img.get_pos() for img in images]