diff options
| author | Michael Williamson <mike@zwobble.org> | 2017-05-14 13:30:38 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2017-05-14 13:30:38 +0100 |
| commit | 54980f619dd055b5797db131f47a3805f4fe4050 (patch) | |
| tree | 941ee90a6e9b6f22f1cb71750c0c361e7ae30698 /tests/images_tests.py | |
| parent | d03970a839cab967a8013ee5d18c74454d3174c1 (diff) | |
Test images.data_uri directly
Diffstat (limited to 'tests/images_tests.py')
| -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"}), + )) |
