Mercurial > hgrepos > Python2 > PyMuPDF
view tests/test_nonpdf.py @ 46:7ee69f120f19 default tip
>>>>> tag v1.26.5+1 for changeset b74429b0f5c4
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 11 Oct 2025 17:17:30 +0200 |
| parents | 1d09e1dec1d9 |
| children |
line wrap: on
line source
""" * Check EPUB document is no PDF * Check page access using (chapter, page) notation * Re-layout EPUB ensuring a previous location is memorized """ import os import pymupdf scriptdir = os.path.abspath(os.path.dirname(__file__)) filename = os.path.join(scriptdir, "resources", "Bezier.epub") doc = pymupdf.open(filename) def test_isnopdf(): assert not doc.is_pdf def test_pageids(): assert doc.chapter_count == 7 assert doc.last_location == (6, 1) assert doc.prev_location((6, 0)) == (5, 11) assert doc.next_location((5, 11)) == (6, 0) # Check page numbers have no gaps: i = 0 for chapter in range(doc.chapter_count): for cpno in range(doc.chapter_page_count(chapter)): assert doc.page_number_from_location((chapter, cpno)) == i i += 1 def test_layout(): """Memorize a page location, re-layout with ISO-A4, assert pre-determined location.""" loc = doc.make_bookmark((5, 11)) doc.layout(pymupdf.Rect(pymupdf.paper_rect("a4"))) assert doc.find_bookmark(loc) == (5, 6)
