diff --git a/tests/test_writer.py b/tests/test_writer.py index b0e38b2ab..f2c2fa192 100644 --- a/tests/test_writer.py +++ b/tests/test_writer.py @@ -169,6 +169,12 @@ def writer_operate(writer: PdfWriter) -> None: ) writer.add_blank_page() writer.add_uri(2, "https://example.com", RectangleObject([0, 0, 100, 100])) + with pytest.warns( + DeprecationWarning, match="'pagenum' argument of add_uri is deprecated" + ): + writer.add_uri( + 2, "https://example.com", RectangleObject([0, 0, 100, 100]), pagenum=2 + ) with pytest.raises(DeprecationError): writer.add_link(2, 1, RectangleObject([0, 0, 100, 100])) assert writer._get_page_layout() is None @@ -179,6 +185,8 @@ def writer_operate(writer: PdfWriter) -> None: assert writer._get_page_mode() is None writer.set_page_mode("/UseNone") assert writer._get_page_mode() == "/UseNone" + writer.set_page_mode(NameObject("/UseOC")) + assert writer._get_page_mode() == "/UseOC" writer.insert_blank_page(width=100, height=100) writer.insert_blank_page() # without parameters @@ -565,6 +573,14 @@ def test_add_named_destination(pdf_file_path): writer.add_named_destination(TextStringObject("A named dest"), 2) writer.add_named_destination(TextStringObject("A named dest2"), 2) + with pytest.warns(DeprecationWarning, match="pagenum is deprecated as an argument"): + writer.add_named_destination(TextStringObject("A named dest3"), pagenum=2) + + with pytest.raises(ValueError): + writer.add_named_destination( + TextStringObject("A named dest3"), pagenum=2, page_number=2 + ) + root = writer.get_named_dest_root() assert root[0] == "A named dest" assert root[1].pdf == writer @@ -574,6 +590,7 @@ def test_add_named_destination(pdf_file_path): assert root[3].pdf == writer assert root[3].get_object()["/S"] == NameObject("/GoTo") assert root[3].get_object()["/D"][0] == writer.pages[2].indirect_reference + assert root[4] == "A named dest3" # test get_object @@ -1263,7 +1280,7 @@ def test_new_removes(): name = "GeoBaseWithComments.pdf" in_pdf = PdfReader(BytesIO(get_pdf_from_url(url, name=name))) out_pdf.append(in_pdf) - out_pdf.remove_objects_from_page(out_pdf.pages[0], ObjectDeletionFlag.LINKS) + out_pdf.remove_objects_from_page(out_pdf.pages[0], [ObjectDeletionFlag.LINKS]) assert "/Links" not in [ a.get_object()["/Subtype"] for a in out_pdf.pages[0]["/Annots"] ] @@ -1285,6 +1302,8 @@ def test_new_removes(): assert len(out_pdf.pages[0]["/Annots"]) == 0 assert len(out_pdf.pages[3]["/Annots"]) == 0 + out_pdf.remove_annotations("/Text") + @pytest.mark.enable_socket() def test_late_iss1654():