def test_images_in_expr(self): img1_path = "hopper.ppm" img2_path = "pal1wb.bmp" with PIL.open(path_to_file_in_data_dir(img1_path)) as img1: with PIL.open(path_to_file_in_data_dir(img2_path)) as img2: res = self.kernel_session.evaluate( wl.Map(wl.ImageDimensions, {"img1": img1, "img2": img2}) ) self.assertEqual( res, { "img1": self.IMAGE_FILES_DIMS[img1_path], "img2": self.IMAGE_FILES_DIMS[img2_path], }, )
def test_png_mode_I(self): with PIL.open(path_to_file_in_data_dir('5x2.png')) as image: self.assertEqual( export(image, target_format='wl'), b'ImportByteArray[ByteArray["iVBORw0KGgoAAAANSUhEUgAAAAUAAAACEAAAAADlkZXCAAAAH0lEQVR4nGP0+P39rf6+ky9/R7Aoen2+9shDWSRCHwCO7ws73c3PRQAAAABJRU5ErkJggg=="], "PNG"]' )
def test_all_char(self): import itertools all_char = u'' unicode_no_surrogate = itertools.chain( range(0xD800), range(1 + 0xDFFF, 1 << 16)) count = 0 for i in unicode_no_surrogate: count += 1 if six.PY2: all_char += unichr(i) else: all_char += chr(i) with open(path_to_file_in_data_dir('allchars.wxf'), 'rb') as r_file: ba = bytearray(r_file.read()) self.serialize_compare(all_char, ba)
def test_images_serialization(self): for path, dimensions in self.IMAGE_FILES_DIMS.items(): with PIL.open(path_to_file_in_data_dir(path)) as img: res = self.kernel_session.evaluate(wl.ImageDimensions(img)) self.assertEqual(res, dimensions)
def test_all_str_py2(self): str_all_chr = b"".join([chr(i) for i in range(0, 256)]) wl_data = export(str_all_chr, target_format="wl") with open(path_to_file_in_data_dir("allbytes.wl"), "rb") as r_file: expected = bytearray(r_file.read()) self.assertSequenceEqual(wl_data, expected)
def test_all_str_py2(self): str_all_chr = b''.join([chr(i) for i in range(0,256)]) wxf = export(str_all_chr, target_format='wxf') with open(path_to_file_in_data_dir('allbytes.wxf'), 'rb') as r_file: res = bytearray(r_file.read()) self.assertSequenceEqual(res, wxf)