Skip to content

Commit

Permalink
STY: Variable naming / opening PDF with PdfReader (#1144)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma authored Jul 21, 2022
1 parent 7cba98a commit 0f52052
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 5 additions & 3 deletions PyPDF2/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,9 +1618,11 @@ class Field(TreeObject):

def __init__(self, data: Dict[str, Any]) -> None:
DictionaryObject.__init__(self)
Field_attributes = FieldDictionaryAttributes.attributes()
Field_attributes = Field_attributes + CheckboxRadioButtonAttributes.attributes()
for attr in Field_attributes:
field_attributes = (
FieldDictionaryAttributes.attributes()
+ CheckboxRadioButtonAttributes.attributes()
)
for attr in field_attributes:
try:
self[NameObject(attr)] = data[attr]
except KeyError:
Expand Down
8 changes: 4 additions & 4 deletions tests/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@


def test_dropdown_items():
with open(os.path.join(RESOURCE_ROOT, "libreoffice-form.pdf"), "rb") as inputfile:
reader = PdfReader(inputfile)
fields = reader.get_fields()
assert "/Opt" in fields["Nationality"].keys()
inputfile = os.path.join(RESOURCE_ROOT, "libreoffice-form.pdf")
reader = PdfReader(inputfile)
fields = reader.get_fields()
assert "/Opt" in fields["Nationality"].keys()


def test_PdfReaderFileLoad():
Expand Down

0 comments on commit 0f52052

Please sign in to comment.