Skip to content

Commit 9395d13

Browse files
committed
ROB: Tests: Test for unencodable text annotation values
1 parent 5b00ebb commit 9395d13

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

tests/test_writer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ def test_named_dest_page_number():
15061506
assert len(writer.root_object["/Names"]["/Dests"]["/Names"]) == 6
15071507

15081508

1509-
def test_update_form_fields(tmp_path):
1509+
def test_update_form_fields(caplog, tmp_path):
15101510
write_data_here = tmp_path / "out.pdf"
15111511
writer = PdfWriter(clone_from=RESOURCE_ROOT / "FormTestFromOo.pdf")
15121512
writer.update_page_form_field_values(
@@ -1572,10 +1572,11 @@ def test_update_form_fields(tmp_path):
15721572
del writer.root_object["/AcroForm"]["/Fields"][1].get_object()["/DR"]["/Font"]
15731573
writer.update_page_form_field_values(
15741574
[writer.pages[0], writer.pages[1]],
1575-
{"Text1": "my Text1", "Text2": "ligne1\nligne2\nligne3"},
1575+
{"Text1": "!مرحبا بالعالم", "Text2": "ligne1\nligne2\nligne3"},
15761576
auto_regenerate=False,
15771577
)
15781578
assert b"/Helv " in writer.pages[1]["/Annots"][1]["/AP"]["/N"].get_data()
1579+
assert "Text string '!مرحبا بالعالم' contains characters not supported by font encoding." in caplog.text
15791580
writer.update_page_form_field_values(
15801581
None,
15811582
{"Text1": "my Text1", "Text2": "ligne1\nligne2\nligne3"},
@@ -1646,7 +1647,7 @@ def test_merge_content_stream_to_page():
16461647

16471648

16481649
@pytest.mark.enable_socket
1649-
def test_update_form_fields2():
1650+
def test_update_form_fields2(caplog):
16501651
my_files = {
16511652
"test1": {
16521653
"name": "Test1 Form",
@@ -1679,7 +1680,7 @@ def test_update_form_fields2():
16791680
"Initial": "JSS",
16801681
# "p2 I DO NOT Agree": "null",
16811682
"p2 Last Name": "Smith",
1682-
"p3 First Name": "John",
1683+
"p3 First Name": "عبدالله",
16831684
"p3 Middle Name": "R",
16841685
"p3 MM": "01",
16851686
"p3 DD": "25",
@@ -1718,12 +1719,13 @@ def test_update_form_fields2():
17181719
"test2.Initial": "JSS",
17191720
"test2.p2 I DO NOT Agree": None,
17201721
"test2.p2 Last Name": "Smith",
1721-
"test2.p3 First Name": "John",
1722+
"test2.p3 First Name": "عبدالله",
17221723
"test2.p3 Middle Name": "R",
17231724
"test2.p3 MM": "01",
17241725
"test2.p3 DD": "25",
17251726
"test2.p3 YY": "21",
17261727
}
1728+
assert "Text string 'عبدالله' contains characters not supported by font encoding." in caplog.text
17271729

17281730

17291731
@pytest.mark.enable_socket

0 commit comments

Comments
 (0)