support/testing: add new test for python-pymupdf
To give us a chance to catch runtime issues (such as missing dependencies) more easily, add a test that writes a sample PDF file, read it back and verify the text that was read. Like similar packages that lead to a big rootfs (e.g. python-botocore), this test requires a separate ext2 rootfs to avoid filling the default amount of RAM available entirely (which would cause missing files from the root filesystem and in turn, test failures). Signed-off-by: Raphaël Mélotte <raphael.melotte@mind.be> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
committed by
Thomas Petazzoni
parent
edfa6f2978
commit
115e9493b8
17
support/testing/tests/package/sample_python_pymupdf.py
Normal file
17
support/testing/tests/package/sample_python_pymupdf.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import fitz
|
||||
|
||||
# Write a test PDF file
|
||||
outfile = "python-pymupdf.pdf"
|
||||
sample_text = "This is a test page for python-pymupdf."
|
||||
doc = fitz.open()
|
||||
page = doc.new_page()
|
||||
p = fitz.Point(50, 72)
|
||||
page.insert_text(p, sample_text)
|
||||
doc.save(outfile)
|
||||
|
||||
# Read back the file
|
||||
with fitz.open(outfile) as d: # open document
|
||||
read_text = chr(12).join([page.get_text() for page in d])
|
||||
|
||||
print(read_text)
|
||||
assert(read_text == sample_text + "\n")
|
||||
Reference in New Issue
Block a user