#!/usr/bin/env python3 """Check all ICO frames and reproducible committed icon assets.""" from pathlib import Path import subprocess import sys import tempfile import unittest from PIL import Image from make_icon import ASSETS, SIZES, render class IconTests(unittest.TestCase): def test_ico_contains_every_size_and_its_rendered_pixels(self): with Image.open(ASSETS / 'FinalToken.ico') as icon: self.assertEqual({(s, s) for s in SIZES}, icon.ico.sizes()) for size in SIZES: frame = icon.ico.getimage((size, size)) self.assertEqual(render(size).tobytes(), frame.tobytes()) def test_fresh_run_reproduces_committed_files_byte_for_byte(self): with tempfile.TemporaryDirectory() as temporary: subprocess.run([sys.executable, '-B', str(Path(__file__).with_name('make_icon.py')), '--out', temporary], check=True) for name in ('FinalToken.ico', 'FinalToken.png'): self.assertEqual((ASSETS / name).read_bytes(), (Path(temporary) / name).read_bytes(), name) if __name__ == '__main__': unittest.main()