|
3 | 3 | import os
|
4 | 4 |
|
5 | 5 | import nbformat.v4 as nbf
|
6 |
| -from nbconvert import LatexExporter, RSTExporter |
| 6 | +from nbconvert import LatexExporter, RSTExporter, NotebookExporter |
7 | 7 | from nbconvert.utils.pandoc import PandocMissing
|
8 | 8 | from nose.plugins.skip import SkipTest
|
9 | 9 | from nose.tools import assert_in, assert_not_in, assert_true
|
@@ -90,3 +90,22 @@ def test_preprocessor_svg2pdf():
|
90 | 90 | assert_true(pdf_existed, 'exported pdf should exist')
|
91 | 91 | assert_in('test.pdf', body,
|
92 | 92 | 'exported pdf should be referenced in exported notebook')
|
| 93 | + |
| 94 | +def test_preprocessor_embedigmages(): |
| 95 | + """Test python embedimages preprocessor.""" |
| 96 | + # check import shortcut |
| 97 | + from jupyter_contrib_nbextensions.nbconvert_support import EmbedImagesPreprocessor # noqa E501 |
| 98 | + notebook_node = nbf.new_notebook(cells=[ |
| 99 | + nbf.new_code_cell(source="a = 'world'"), |
| 100 | + nbf.new_markdown_cell( |
| 101 | + source="".format(path_in_data('icon.png')) |
| 102 | + ), |
| 103 | + ]) |
| 104 | + customconfig = Config(EmbedImagesPreprocessor={'embed_images': True}) |
| 105 | + body, resources = export_through_preprocessor( |
| 106 | + notebook_node, EmbedImagesPreprocessor, NotebookExporter, 'ipynb', customconfig) |
| 107 | + |
| 108 | + expected = 'image/png' |
| 109 | + assert_in(expected, body, 'Attachment {} is missing'.format(expected)) |
| 110 | + |
| 111 | + |
0 commit comments