test format constraint, and validity of jpeg and png
()
| 119 | display.Image("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB94BCRQnOqNu0b4AAAAKSURBVAjXY2AAAAACAAHiIbwzAAAAAElFTkSuQmCC") |
| 120 | |
| 121 | def test_image_filename_defaults(): |
| 122 | '''test format constraint, and validity of jpeg and png''' |
| 123 | tpath = ipath.get_ipython_package_dir() |
| 124 | nt.assert_raises(ValueError, display.Image, filename=os.path.join(tpath, 'testing/tests/badformat.zip'), |
| 125 | embed=True) |
| 126 | nt.assert_raises(ValueError, display.Image) |
| 127 | nt.assert_raises(ValueError, display.Image, data='this is not an image', format='badformat', embed=True) |
| 128 | # check boths paths to allow packages to test at build and install time |
| 129 | imgfile = os.path.join(tpath, 'core/tests/2x2.png') |
| 130 | img = display.Image(filename=imgfile) |
| 131 | nt.assert_equal('png', img.format) |
| 132 | nt.assert_is_not_none(img._repr_png_()) |
| 133 | img = display.Image(filename=os.path.join(tpath, 'testing/tests/logo.jpg'), embed=False) |
| 134 | nt.assert_equal('jpeg', img.format) |
| 135 | nt.assert_is_none(img._repr_jpeg_()) |
| 136 | |
| 137 | def _get_inline_config(): |
| 138 | from ipykernel.pylab.config import InlineBackend |
nothing calls this directly
no test coverage detected