File tree Expand file tree Collapse file tree
test_unstructured/partition Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -372,11 +372,16 @@ def test_partition_email_can_process_attachments():
372372
373373
374374def 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." ),
You can’t perform that action at this time.
0 commit comments