def test(self): import pystacia from pystacia import image with catch_warnings(record=True) as w: simplefilter('always') self.assertTrue( image.blank(30, 30).is_same(pystacia.blank(30, 30))) self.assertTrue('blank' in w[-1].message.args[0]) if lena_available(): self.assertTrue(image.lena().is_same(pystacia.lena())) self.assertTrue('lena' in w[-1].message.args[0]) tmpname = mkstemp()[1] + '.bmp' img = sample() img.write(tmpname) self.assertTrue( pystacia.read(tmpname).is_same(image.read(tmpname))) self.assertTrue('read' in w[-1].message.args[0]) self.assertTrue( pystacia.read_blob(img.get_blob('bmp')).is_same( image.read_blob(img.get_blob('bmp')))) self.assertTrue( pystacia.read_raw(**img.get_raw('rgb')).is_same( image.read_raw(**img.get_raw('rgb')))) img.close() for symbol in [ 'magick_logo', 'wizard', 'netscape', 'granite', 'rose' ]: self.assertTrue( getattr(image, symbol)().is_same(getattr(pystacia, symbol)())) self.assertTrue(symbol in w[-1].message.args[0]) self.assertIsInstance(pystacia.Image(), image.Image) names = [ 'composites', 'types', 'filters', 'colorspaces', 'compressions', 'axes' ] for name in names: self.assertEqual( getattr(pystacia, name).x, getattr(image, name).x) self.assertTrue(name in w[-1].message.args[0])
def test_read_blob(self): img = self.img bmp = img.get_blob('bmp') bmp2 = img.get_blob('bmp', factory=BytesIO) self.assertEqual(bmp, bmp2.read()) for i in (bmp, BytesIO(bmp)): img = read_blob(i) self.assertEqual(img.size, sample_size) self.assertEqual(img.type, sample_type) self.assertTrue(img.colorspace.name.endswith('rgb')) self.assertEqual(img.depth, 8)
def test(self): import pystacia from pystacia import image with catch_warnings(record=True) as w: simplefilter('always') self.assertTrue(image.blank(30, 30). is_same(pystacia.blank(30, 30))) self.assertTrue('blank' in w[-1].message.args[0]) if lena_available(): self.assertTrue(image.lena().is_same(pystacia.lena())) self.assertTrue('lena' in w[-1].message.args[0]) tmpname = mkstemp()[1] + '.bmp' img = sample() img.write(tmpname) self.assertTrue(pystacia.read(tmpname). is_same(image.read(tmpname))) self.assertTrue('read' in w[-1].message.args[0]) self.assertTrue(pystacia.read_blob(img.get_blob('bmp')). is_same(image.read_blob(img.get_blob('bmp')))) self.assertTrue(pystacia.read_raw(**img.get_raw('rgb')). is_same(image.read_raw(**img.get_raw('rgb')))) img.close() for symbol in ['magick_logo', 'wizard', 'netscape', 'granite', 'rose']: self.assertTrue(getattr(image, symbol)(). is_same(getattr(pystacia, symbol)())) self.assertTrue(symbol in w[-1].message.args[0]) self.assertIsInstance(pystacia.Image(), image.Image) names = ['composites', 'types', 'filters', 'colorspaces', 'compressions', 'axes'] for name in names: self.assertEqual(getattr(pystacia, name).x, getattr(image, name).x) self.assertTrue(name in w[-1].message.args[0])