def test_image_filename_defaults():
 tpath = ipath.get_ipython_package_dir()
 nt.assert_raises(ValueError, display.Image, filename=os.path.join(tpath, 'testing/tests/badformat.gif'), embed=True)
 nt.assert_raises(ValueError, display.Image)
 nt.assert_raises(ValueError, display.Image, data='this is not an image', format='badformat', embed=True)
 imgfile = os.path.join(tpath, 'core/tests/2x2.png')
 img = display.Image(filename=imgfile)
 nt.assert_equal('png', img.format)
 nt.assert_is_not_none(img._repr_png_())
 img = display.Image(filename=os.path.join(tpath, 'testing/tests/logo.jpg'), embed=False)
 nt.assert_equal('jpeg', img.format)
 nt.assert_is_none(img._repr_jpeg_())

def test_image_filename_defaults ( ) : tpath = ipath . get_ipython_package_dir ( ) nt . assert_raises ( ValueError , display . Image , filename = os . path . join ( tpath , 'testing/tests/badformat.gif' ) , embed = True ) nt . assert_raises ( ValueError , display . Image ) nt . assert_raises ( ValueError , display . Image , data = 'this is not an image' , format = 'badformat' , embed = True ) imgfile = os . path . join ( tpath , 'core/tests/2x2.png' ) img = display . Image ( filename = imgfile ) nt . assert_equal ( 'png' , img . format ) nt . assert_is_not_none ( img . _repr_png_ ( ) ) img = display . Image ( filename = os . path . join ( tpath , 'testing/tests/logo.jpg' ) , embed = False ) nt . assert_equal ( 'jpeg' , img . format ) nt . assert_is_none ( img . _repr_jpeg_ ( ) )
test format constraint .