Skip to content

Commit c033e10

Browse files
authored
Merge pull request #1529 from cbm755/test1417
test: insertpdf in a loop with context manager
2 parents f0a614e + ed9aec3 commit c033e10

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/test_insertpdf.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Compare with stored earlier result:
44
- must have identical object definitions
55
- must have different trailers
6+
* Try inserting files in a loop.
67
"""
78
import os
89

@@ -35,3 +36,13 @@ def test_joining():
3536
)
3637
assert old_output.xref_get_keys(-1) == new_output.xref_get_keys(-1)
3738
assert old_output.xref_get_key(-1, "ID") != new_output.xref_get_key(-1, "ID")
39+
40+
41+
def test_issue1417_insertpdf_in_loop():
42+
"""Using a context manager instead of explicitly closing files"""
43+
f = os.path.join(resources, "1.pdf")
44+
big_doc = fitz.open()
45+
for n in range(0, 1025):
46+
with fitz.open(f) as pdf:
47+
big_doc.insert_pdf(pdf)
48+
big_doc.close()

0 commit comments

Comments
 (0)