aboutsummaryrefslogtreecommitdiff
path: root/tests/mammoth_tests.py
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-08-20 20:34:34 +0100
committerMichael Williamson <mike@zwobble.org>2015-08-20 20:35:14 +0100
commit1c14ed25d75caf3228a92d8f7292bf0bf040653b (patch)
treeaa36f672e71baebf7b870a8be609d1990dd450e3 /tests/mammoth_tests.py
parent06ac97ac681accc691affdfafec97ded54faba23 (diff)
Fix: cannot read file objects with name attribute
Diffstat (limited to 'tests/mammoth_tests.py')
-rw-r--r--tests/mammoth_tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/mammoth_tests.py b/tests/mammoth_tests.py
index ddcb9a6..89336b3 100644
--- a/tests/mammoth_tests.py
+++ b/tests/mammoth_tests.py
@@ -2,6 +2,9 @@
from __future__ import unicode_literals
+import io
+import shutil
+
from nose.tools import istest, assert_equal
from .testing import test_path
@@ -67,6 +70,17 @@ def images_stored_outside_of_document_are_included_in_output():
result = mammoth.convert_to_html(fileobj=fileobj)
assert_equal("""<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAAlwSFlzAAAOvgAADr4B6kKxwAAAABNJREFUKFNj/M+ADzDhlWUYqdIAQSwBE8U+X40AAAAASUVORK5CYII=" /></p>""", result.value)
assert_equal([], result.messages)
+
+
+@istest
+def warn_if_images_stored_outside_of_document_are_specified_when_passing_fileobj_without_name():
+ fileobj = io.BytesIO()
+ with open(test_path("external-picture.docx"), "rb") as source_fileobj:
+ shutil.copyfileobj(source_fileobj, 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