Mercurial > hgrepos > Python2 > PyMuPDF
comparison tests/test_nonpdf.py @ 1:1d09e1dec1d9 upstream
ADD: PyMuPDF v1.26.4: the original sdist.
It does not yet contain MuPDF. This normally will be downloaded when
building PyMuPDF.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:37:51 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 1:1d09e1dec1d9 |
|---|---|
| 1 """ | |
| 2 * Check EPUB document is no PDF | |
| 3 * Check page access using (chapter, page) notation | |
| 4 * Re-layout EPUB ensuring a previous location is memorized | |
| 5 """ | |
| 6 import os | |
| 7 | |
| 8 import pymupdf | |
| 9 | |
| 10 scriptdir = os.path.abspath(os.path.dirname(__file__)) | |
| 11 filename = os.path.join(scriptdir, "resources", "Bezier.epub") | |
| 12 doc = pymupdf.open(filename) | |
| 13 | |
| 14 | |
| 15 def test_isnopdf(): | |
| 16 assert not doc.is_pdf | |
| 17 | |
| 18 | |
| 19 def test_pageids(): | |
| 20 assert doc.chapter_count == 7 | |
| 21 assert doc.last_location == (6, 1) | |
| 22 assert doc.prev_location((6, 0)) == (5, 11) | |
| 23 assert doc.next_location((5, 11)) == (6, 0) | |
| 24 # Check page numbers have no gaps: | |
| 25 i = 0 | |
| 26 for chapter in range(doc.chapter_count): | |
| 27 for cpno in range(doc.chapter_page_count(chapter)): | |
| 28 assert doc.page_number_from_location((chapter, cpno)) == i | |
| 29 i += 1 | |
| 30 | |
| 31 def test_layout(): | |
| 32 """Memorize a page location, re-layout with ISO-A4, assert pre-determined location.""" | |
| 33 loc = doc.make_bookmark((5, 11)) | |
| 34 doc.layout(pymupdf.Rect(pymupdf.paper_rect("a4"))) | |
| 35 assert doc.find_bookmark(loc) == (5, 6) |
