diff options
| author | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:34:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2015-08-20 20:35:14 +0100 |
| commit | 1c14ed25d75caf3228a92d8f7292bf0bf040653b (patch) | |
| tree | aa36f672e71baebf7b870a8be609d1990dd450e3 /tests | |
| parent | 06ac97ac681accc691affdfafec97ded54faba23 (diff) | |
Fix: cannot read file objects with name attribute
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/docx/body_xml_tests.py | 1 | ||||
| -rw-r--r-- | tests/mammoth_tests.py | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tests/docx/body_xml_tests.py b/tests/docx/body_xml_tests.py index 6122706..da662d8 100644 --- a/tests/docx/body_xml_tests.py +++ b/tests/docx/body_xml_tests.py @@ -406,6 +406,7 @@ class ReadXmlElementTests(object): }) files = context.mock() + funk.allows(files).verify("file:///media/hat.png") funk.allows(files).open("file:///media/hat.png").returns(io.BytesIO(image_bytes)) content_types = context.mock() 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 |
