set python compatibility 3.6 -> 3.2
This commit is contained in:
27
tests/format-support.py
Executable file → Normal file
27
tests/format-support.py
Executable file → Normal file
@@ -50,13 +50,13 @@ def generate_raw_rgb():
|
||||
|
||||
os.makedirs('format-support-raw', exist_ok=True)
|
||||
for s in INFO.keys():
|
||||
print(f'generate {s}x{s}.argb')
|
||||
print('generate {}x{}.argb'.format(s, s))
|
||||
argb_data = testpattern(s, s, ch=4)
|
||||
with open(f'format-support-raw/{s}x{s}.argb', 'wb') as fp:
|
||||
with open('format-support-raw/{}x{}.argb'.format(s, s), 'wb') as fp:
|
||||
fp.write(argb_data)
|
||||
print(f'generate {s}x{s}.rgb')
|
||||
print('generate {}x{}.rgb'.format(s, s))
|
||||
rgb_data = testpattern(s, s, ch=3)
|
||||
with open(f'format-support-raw/{s}x{s}.rgb', 'wb') as fp:
|
||||
with open('format-support-raw/{}x{}.rgb'.format(s, s), 'wb') as fp:
|
||||
fp.write(rgb_data)
|
||||
|
||||
|
||||
@@ -64,18 +64,18 @@ def generate_icns():
|
||||
os.makedirs('format-support-icns', exist_ok=True)
|
||||
with zipfile.ZipFile('format-support-raw.zip') as Zip:
|
||||
for s, keys in INFO.items():
|
||||
print(f'generate icns for {s}x{s}')
|
||||
print('generate icns for {}x{}'.format(s, s))
|
||||
for key in keys:
|
||||
# JPEG 2000, PNG, and ARGB
|
||||
for ext in ['jp2', 'png', 'argb']:
|
||||
img = IcnsFile()
|
||||
with Zip.open(f'{s}x{s}.{ext}') as f:
|
||||
with Zip.open('{}x{}.{}'.format(s, s, ext)) as f:
|
||||
img.add_media(key, data=f.read())
|
||||
img.write(f'format-support-icns/{s}-{key}-{ext}.icns',
|
||||
toc=False)
|
||||
img.write('format-support-icns/{}-{}-{}.icns'.format(
|
||||
s, key, ext), toc=False)
|
||||
# RGB + mask
|
||||
img = IcnsFile()
|
||||
with Zip.open(f'{s}x{s}.rgb') as f:
|
||||
with Zip.open('{}x{}.rgb'.format(s, s)) as f:
|
||||
data = f.read()
|
||||
if key == 'it32':
|
||||
data = b'\x00\x00\x00\x00' + data
|
||||
@@ -84,14 +84,15 @@ def generate_icns():
|
||||
img.add_media('l8mk', data=b'\xFF' * 1024)
|
||||
img.add_media('h8mk', data=b'\xFF' * 2304)
|
||||
img.add_media('t8mk', data=b'\xFF' * 16384)
|
||||
img.write(f'format-support-icns/{s}-{key}-rgb.icns', toc=False)
|
||||
img.write('format-support-icns/{}-{}-rgb.icns'.format(s, key),
|
||||
toc=False)
|
||||
|
||||
|
||||
def generate_random_it32_header():
|
||||
print(f'testing random it32 header')
|
||||
print('testing random it32 header')
|
||||
os.makedirs('format-support-it32', exist_ok=True)
|
||||
with zipfile.ZipFile('format-support-raw.zip') as Zip:
|
||||
with Zip.open(f'128x128.rgb') as f:
|
||||
with Zip.open('128x128.rgb') as f:
|
||||
data = f.read()
|
||||
|
||||
def random_header():
|
||||
@@ -102,7 +103,7 @@ def generate_random_it32_header():
|
||||
img = IcnsFile()
|
||||
img.add_media('it32', data=random_header() + data)
|
||||
img.add_media('t8mk', data=b'\xFF' * 16384)
|
||||
img.write(f'format-support-it32/{i}.icns', toc=False)
|
||||
img.write('format-support-it32/{}.icns'.format(i), toc=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
8
tests/test_icnsutil.py
Executable file → Normal file
8
tests/test_icnsutil.py
Executable file → Normal file
@@ -207,8 +207,10 @@ class TestIcnsType(unittest.TestCase):
|
||||
('icp6', 'png', '', (64, 64), None),
|
||||
('ic14', 'png', '@2x', (512, 512), None),
|
||||
('info', 'plist', '', None, None),
|
||||
] + [(x.value, 'icns', '', None, None)
|
||||
for x in IcnsType.Role]:
|
||||
('sbtp', 'icns', 'template', None, None),
|
||||
('slct', 'icns', 'selected', None, None),
|
||||
(b'\xFD\xD9\x2F\xA8', 'icns', 'dark', None, None),
|
||||
]:
|
||||
m = IcnsType.get(key)
|
||||
self.assertEqual(m.size, size)
|
||||
self.assertTrue(m.is_type(ext))
|
||||
@@ -227,7 +229,7 @@ class TestIcnsType(unittest.TestCase):
|
||||
x = IcnsType.guess(fp.read(), 'rgb.icns.argb')
|
||||
self.assertTrue(x.is_type('argb'))
|
||||
self.assertEqual(x.size, (16, 16))
|
||||
self.assertEqual(x.retina, None)
|
||||
self.assertEqual(x.retina, False)
|
||||
self.assertEqual(x.channels, 4)
|
||||
self.assertEqual(x.compressable, True)
|
||||
with open('256x256.jp2', 'rb') as fp:
|
||||
|
||||
Reference in New Issue
Block a user