MCPcopy Create free account
hub / github.com/ipython/ipython / test_image_filename_defaults

Function test_image_filename_defaults

IPython/core/tests/test_display.py:121–135  ·  view source on GitHub ↗

test format constraint, and validity of jpeg and png

()

Source from the content-addressed store, hash-verified

119 display.Image("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB94BCRQnOqNu0b4AAAAKSURBVAjXY2AAAAACAAHiIbwzAAAAAElFTkSuQmCC")
120
121def 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
137def _get_inline_config():
138 from ipykernel.pylab.config import InlineBackend

Callers

nothing calls this directly

Calls 2

_repr_png_Method · 0.95
_repr_jpeg_Method · 0.95

Tested by

no test coverage detected