diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:41:28 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:41:28 +0100 |
| commit | 9c326a3db4c0bf50210fb7a4b8e9817d5d88e296 (patch) | |
| tree | 62edfd648a63a5945d75ffa4318ba9640c4cc206 /tests | |
| parent | 1c14ed25d75caf3228a92d8f7292bf0bf040653b (diff) | |
Raise error if external image cannot be found
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/mammoth_tests.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py index 89336b3..aa70c1c 100644 --- a/tests/mammoth_tests.py +++ b/tests/mammoth_tests.py @@ -4,7 +4,9 @@ from __future__ import unicode_literals import io import shutil +import os +import tempman from nose.tools import istest, assert_equal from .testing import test_path @@ -81,6 +83,21 @@ def warn_if_images_stored_outside_of_document_are_specified_when_passing_fileobj result = mammoth.convert_to_html(fileobj=fileobj) assert_equal("", result.value) assert_equal([results.warning("could not find external image 'tiny-picture.png', fileobj has no name")], result.messages) + + +@istest +def warn_if_images_stored_outside_of_document_are_not_found(): + with tempman.create_temp_dir() as temp_dir: + document_path = os.path.join(temp_dir.path, "document.docx") + with open(document_path, "wb") as fileobj: + with open(test_path("external-picture.docx"), "rb") as source_fileobj: + shutil.copyfileobj(source_fileobj, fileobj) + + with open(document_path, "rb") as fileobj: + result = mammoth.convert_to_html(fileobj=fileobj) + assert_equal("", result.value) + expected_warning = "could not find external image 'tiny-picture.png' from document directory '{0}'".format(temp_dir.path) + assert_equal([results.warning(expected_warning)], result.messages) @istest |
