Skip to content

Commit

Permalink
TST: Various PdfWriter (Layout, Bookmark deprecation) (#1249)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma authored Aug 17, 2022
1 parent 28cf36a commit cb6c224
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PyPDF2/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def add_bookmark(
italic: bool = False,
fit: FitType = "/Fit",
*args: ZoomArgType,
) -> IndirectObject:
) -> IndirectObject: # pragma: no cover
"""
.. deprecated:: 2.9.0
Expand Down
12 changes: 12 additions & 0 deletions tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,18 @@ def test_issue_997(mock_logger_warning):
"Overwriting cache for 0 4", "PyPDF2._reader"
)

# Strict
merger = PdfMerger(strict=True)
merged_filename = "tmp-out.pdf"
with pytest.raises(PdfReadError) as exc:
merger.append(
BytesIO(get_pdf_from_url(url, name=name))
) # here the error raises
assert exc.value.args[0] == "Could not find object."
with open(merged_filename, "wb") as f:
merger.write(f)
merger.close()

# cleanup
os.remove(merged_filename)

Expand Down
5 changes: 3 additions & 2 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ def writer_operate(writer):
with pytest.warns(PendingDeprecationWarning):
writer.add_link(2, 1, RectangleObject([0, 0, 100, 100]))
assert writer._get_page_layout() is None
writer._set_page_layout("broken")
writer._set_page_layout("/SinglePage")
writer.page_layout = "broken"
assert writer.page_layout == "broken"
writer.page_layout = NameObject("/SinglePage")
assert writer._get_page_layout() == "/SinglePage"
assert writer._get_page_mode() is None
writer.set_page_mode("/UseNone")
Expand Down

0 comments on commit cb6c224

Please sign in to comment.