Skip to content

Commit 9eb779d

Browse files
fix: test
1 parent 268e31d commit 9eb779d

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

test_unstructured/partition/test_email.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,16 @@ def test_partition_email_can_process_attachments():
372372

373373

374374
def test_partition_email_silently_skips_attachments_it_cannot_partition():
375-
elements = partition_email(
376-
example_doc_path("eml/mime-attach-mp3.eml"), process_attachments=True
377-
)
375+
"""Attachments that raise EXPECTED_ATTACHMENT_ERRORS (e.g. ImportError) are skipped."""
376+
from unittest.mock import patch
377+
378+
with patch("unstructured.partition.auto.partition") as mock_partition:
379+
mock_partition.side_effect = ImportError("No module named 'whisper'")
380+
elements = partition_email(
381+
example_doc_path("eml/mime-attach-mp3.eml"), process_attachments=True
382+
)
378383

379-
# -- no exception is raised --
384+
# -- No exception; attachment skipped (ImportError is in EXPECTED_ATTACHMENT_ERRORS). --
380385
assert elements == [
381386
# -- the email body is partitioned --
382387
NarrativeText("This is an email with an MP3 attachment."),

0 commit comments

Comments
 (0)