Skip to content

Commit

Permalink
STY: Rename create_viewer_preference -> create_viewer_preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
marcstober committed Sep 12, 2023
1 parent c587cee commit 6d41025
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pypdf/_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def viewer_preferences(self) -> Optional[ViewerPreferences]:
self._root_object[NameObject(CD.VIEWER_PREFERENCES)] = o
return o

def create_viewer_preference(self) -> ViewerPreferences:
def create_viewer_preferences(self) -> ViewerPreferences:
o = ViewerPreferences()
self._root_object[NameObject(CD.VIEWER_PREFERENCES)] = self._add_object(o)
return o
Expand Down
9 changes: 4 additions & 5 deletions tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1725,10 +1725,7 @@ def test_damaged_pdf_length_returning_none():

@pytest.mark.enable_socket()
def test_viewerpreferences():
"""
Add Tests for ViewerPreferences
https://github.com/py-pdf/pypdf/issues/140#issuecomment-1685380549
"""
"""Add Tests for ViewerPreferences"""
url = "https://github.com/py-pdf/pypdf/files/9175966/2015._pb_decode_pg0.pdf"
name = "2015._pb_decode_pg0.pdf"
reader = PdfReader(BytesIO(get_data_from_url(url, name=name)))
Expand Down Expand Up @@ -1779,8 +1776,10 @@ def test_viewerpreferences():
v.print_pagerange = ArrayObject()
assert len(v.print_pagerange) == 0

writer.create_viewer_preference()
writer.create_viewer_preferences()
assert len(writer._root_object["/ViewerPreferences"]) == 0
writer.viewer_preferences.direction = "/R2L"
assert len(writer._root_object["/ViewerPreferences"]) == 1

del reader.trailer["/Root"]["/ViewerPreferences"]
assert reader.viewer_preferences is None
Expand Down

0 comments on commit 6d41025

Please sign in to comment.