def test_image_filename_defaults():
'''test format constraint, and validity of jpeg and png'''
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)
# check boths paths to allow packages to test at build and install time
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_())
python类assert_is_not_none()的实例源码
def test_builtin_init():
info = inspector.info(list)
init_def = info['init_definition']
# Python < 3.4 can't get init definition from builtins,
# but still exercise the inspection in case of error-raising bugs.
if sys.version_info >= (3,4):
nt.assert_is_not_none(init_def)
def test_image_filename_defaults():
'''test format constraint, and validity of jpeg and png'''
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)
# check boths paths to allow packages to test at build and install time
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_builtin_init():
info = inspector.info(list)
init_def = info['init_definition']
# Python < 3.4 can't get init definition from builtins,
# but still exercise the inspection in case of error-raising bugs.
if sys.version_info >= (3,4):
nt.assert_is_not_none(init_def)
def assert_error(code, response):
nt.assert_equal(response.status_code, code)
nt.assert_equal(response.content_type, 'application/json')
jr = json.loads(response.get_data(as_text=True))
nt.assert_equal(jr['status'], 'error')
nt.assert_is_not_none(jr['message'])
return jr
def test_get_root(self):
resp = assert_ok(200, self.client.get('/v1'))
nt.assert_is_not_none(resp['version'])
def test_file_path_url(self):
img_args_fp, _ = jobs.gcv_params(self.file_path)
nt.assert_is_not_none(img_args_fp)
img_args_url, _ = jobs.gcv_params(self.file_url)
nt.assert_is_not_none(img_args_url)
nt.assert_true(img_args_fp.keys() != img_args_url.keys)
def test_convert_poly(self):
gps = jobs.detect_exif_gps(self.file_path_gps)
gps_poly = jobs.make_poly(gps[0], gps[1], 0.00001)
nt.assert_is_not_none(gps_poly)
nt.assert_true(gps_poly.startswith('POLYGON('))
def test_image_filename_defaults():
'''test format constraint, and validity of jpeg and png'''
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)
# check boths paths to allow packages to test at build and install time
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_builtin_init():
info = inspector.info(list)
init_def = info['init_definition']
# Python < 3.4 can't get init definition from builtins,
# but still exercise the inspection in case of error-raising bugs.
if sys.version_info >= (3,4):
nt.assert_is_not_none(init_def)
def test_image_filename_defaults():
'''test format constraint, and validity of jpeg and png'''
tpath = ipath.get_ipython_package_dir()
nt.assert_raises(ValueError, display.Image, filename=os.path.join(tpath, 'testing/tests/badformat.zip'),
embed=True)
nt.assert_raises(ValueError, display.Image)
nt.assert_raises(ValueError, display.Image, data='this is not an image', format='badformat', embed=True)
# check boths paths to allow packages to test at build and install time
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_builtin_init():
info = inspector.info(list)
init_def = info['init_definition']
# Python < 3.4 can't get init definition from builtins,
# but still exercise the inspection in case of error-raising bugs.
if sys.version_info >= (3,4):
nt.assert_is_not_none(init_def)