diff options
| -rw-r--r-- | tests/images_tests.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/images_tests.py b/tests/images_tests.py index c3d1689..cf2e284 100644 --- a/tests/images_tests.py +++ b/tests/images_tests.py @@ -1,3 +1,6 @@ +import io + +from hamcrest import assert_that, contains, has_properties from nose.tools import istest import mammoth @@ -6,3 +9,19 @@ import mammoth @istest def inline_is_available_as_alias_of_img_element(): assert mammoth.images.inline is mammoth.images.img_element + + +@istest +def data_uri_encodes_images_in_base64(): + image_bytes = b"abc" + image = mammoth.documents.Image( + alt_text=None, + content_type="image/jpeg", + open=lambda: io.BytesIO(image_bytes), + ) + + result = mammoth.images.data_uri(image) + + assert_that(result, contains( + has_properties(attributes={"src": "data:image/jpeg;base64,YWJj"}), + )) |
