def test_raw(self): data = dict(raw=b('\xff\xff\xff'), format='rgb', depth=8, width=1, height=1) img = read_raw(**data) self.assertEqual(img.size, (1, 1)) self.assertEqual(img.depth, 8) self.assertEqual(img.get_blob('rgb'), data['raw']) self.assertDictEqual(img.get_raw('rgb'), data) self.assertEqual(img.get_pixel(0, 0), color.from_string('white')) data = dict(raw=BytesIO(b('\xff\xff\xff')), format='rgb', depth=8, width=1, height=1) img2 = read_raw(**data) self.assertTrue(img.is_same(img2)) img.close() img2.close()
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(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])