Skip to content

Commit 0a7370a

Browse files
committed
remove unnecessary log
1 parent a487104 commit 0a7370a

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

_test_unstructured_client/unit/test_split_pdf_hook.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def test_unit_is_pdf_valid_pdf():
237237
assert result is True
238238

239239

240-
def test_unit_is_pdf_valid_pdf_without_file_extension(caplog):
240+
def test_unit_is_pdf_valid_pdf_without_file_extension():
241241
"""Test is pdf method returns True for file with valid pdf content without basing on file extension."""
242242
filename = "_sample_docs/layout-parser-paper-fast.pdf"
243243

@@ -252,36 +252,31 @@ def test_unit_is_pdf_valid_pdf_without_file_extension(caplog):
252252
assert result is True
253253

254254

255-
def test_unit_is_pdf_invalid_extension(caplog):
255+
def test_unit_is_pdf_invalid_extension():
256256
"""Test is pdf method returns False for file with invalid extension."""
257257
file = shared.Files(content=b"txt_content", file_name="test_file.txt")
258258

259-
with caplog.at_level(logging.WARNING):
260-
result = pdf_utils.is_pdf(file)
259+
result = pdf_utils.is_pdf(file)
261260

262261
assert result is False
263-
assert "The file does not appear to be a valid PDF." in caplog.text
264262

265263

266-
def test_unit_is_pdf_invalid_pdf(caplog):
264+
def test_unit_is_pdf_invalid_pdf():
267265
"""Test is pdf method returns False for file with invalid pdf content."""
268266
file = shared.Files(content=b"invalid_pdf_content", file_name="test_file.pdf")
269267

270-
with caplog.at_level(logging.WARNING):
271-
result = pdf_utils.is_pdf(file)
268+
result = pdf_utils.is_pdf(file)
272269

273270
assert result is False
274-
assert "The file does not appear to be a valid PDF." in caplog.text
275271

276-
def test_unit_is_pdf_invalid_pdf_without_file_extension(caplog):
272+
273+
def test_unit_is_pdf_invalid_pdf_without_file_extension():
277274
"""Test is pdf method returns False for file with invalid pdf content without basing on file extension."""
278275
file = shared.Files(content=b"invalid_pdf_content", file_name="uuid1234")
279276

280-
with caplog.at_level(logging.WARNING):
281-
result = pdf_utils.is_pdf(file)
277+
result = pdf_utils.is_pdf(file)
282278

283279
assert result is False
284-
assert "The file does not appear to be a valid PDF." in caplog.text
285280

286281

287282
def test_unit_get_starting_page_number_missing_key():

src/unstructured_client/_hooks/custom/pdf_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def is_pdf(file: shared.Files) -> bool:
6868
try:
6969
content = cast(bytes, file.content)
7070
PdfReader(io.BytesIO(content), strict=True)
71-
except (PdfReadError, UnicodeDecodeError) as exc:
72-
logger.error(exc)
73-
logger.warning("The file does not appear to be a valid PDF.")
71+
except (PdfReadError, UnicodeDecodeError):
7472
return False
7573

7674
return True

0 commit comments

Comments
 (0)