Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
Coniferish committed Jan 18, 2025
1 parent bc19db2 commit e2d82e5
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions test_unstructured/partition/pdf_image/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1525,10 +1525,9 @@ def test_document_to_element_list_sets_category_depth_titles():
# fast: can't capture the "intentionally left blank page" page
# others: will ignore the actual blank page
[
(PartitionStrategy.FAST, {"pdfminer"}),
(PartitionStrategy.FAST, {"pdfminer"}),
(PartitionStrategy.FAST, {"pdfminer"}),
(PartitionStrategy.HI_RES, {"yolox", "pdfminer", "ocr_tesseract"}),
(PartitionStrategy.OCR_ONLY, {"ocr_tesseract"}),
(PartitionStrategy.OCR_ONLY, {"ocr_tesseract"}),
],
)
def test_partition_pdf_with_password(
Expand All @@ -1541,28 +1540,21 @@ def test_partition_pdf_with_password(
def _test(result):
# validate that the result is a non-empty list of dicts
assert len(result) == 1
assert result[0].text == 'File with password'
assert result[0].text == "File with password"

if file_mode == "filename":
result = pdf.partition_pdf(
filename=filename, strategy=strategy,
password="password"
)
result = pdf.partition_pdf(filename=filename, strategy=strategy, password="password")
_test(result)
elif file_mode == "rb":
with open(filename, "rb") as f:
result = pdf.partition_pdf(
file=f, strategy=strategy,
password="password"
)
result = pdf.partition_pdf(file=f, strategy=strategy, password="password")
_test(result)
else:
with open(filename, "rb") as test_file:
spooled_temp_file = SpooledTemporaryFile()
spooled_temp_file.write(test_file.read())
spooled_temp_file.seek(0)
result = pdf.partition_pdf(
file=spooled_temp_file, strategy=strategy,
password="password"
file=spooled_temp_file, strategy=strategy, password="password"
)
_test(result)

0 comments on commit e2d82e5

Please sign in to comment.