From 0f520528b881688e7324ee5aab3c379dac678e1f Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Thu, 21 Jul 2022 18:53:15 +0200 Subject: [PATCH] STY: Variable naming / opening PDF with PdfReader (#1144) --- PyPDF2/generic.py | 8 +++++--- tests/test_workflows.py | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/PyPDF2/generic.py b/PyPDF2/generic.py index 42cb1815a..91a47307e 100644 --- a/PyPDF2/generic.py +++ b/PyPDF2/generic.py @@ -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: diff --git a/tests/test_workflows.py b/tests/test_workflows.py index 7ef216f82..47b2f3e56 100644 --- a/tests/test_workflows.py +++ b/tests/test_workflows.py @@ -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():