1c306ae391
- assets/icon.png + icon.ico (16-256 px), gezeichnet von assets/make_icon.py - app/version.py: Name, Version, Beschreibung, Copyright an einer Stelle - build.py: Windows-.exe mit --icon und --version-file (Eigenschaften -> Details); icon.png wird ins Programm gepackt; Archive mit Versionsnummer; Linux-Archiv mit icon.png und install-desktop.sh (Startmenü-Eintrag) - app/viewer.py: Fenster-Icon zur Laufzeit (auch Linux), Version im Titel - tests/test_icon_version.py, README, build.yml (Artefakt-Name) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.7 KiB
Python
48 lines
1.7 KiB
Python
"""Icon und Versionsinfo (assets/, app/version.py, build.py)."""
|
|
|
|
import ast
|
|
import struct
|
|
import sys
|
|
|
|
import pytest
|
|
from PySide6.QtGui import QIcon, QImage
|
|
|
|
import viewer
|
|
from conftest import PROJECT
|
|
from version import APP_NAME, COPYRIGHT, VERSION
|
|
|
|
|
|
def test_icon_files_are_valid():
|
|
png = QImage(str(PROJECT / "assets" / "icon.png"))
|
|
assert not png.isNull() and png.width() == png.height() == 256
|
|
data = (PROJECT / "assets" / "icon.ico").read_bytes()
|
|
reserved, kind, count = struct.unpack("<HHH", data[:6])
|
|
assert (reserved, kind) == (0, 1) and count >= 5 # mehrere Grössen
|
|
sizes = {data[6 + 16 * i] or 256 for i in range(count)}
|
|
assert {16, 32, 48, 256} <= sizes
|
|
|
|
|
|
def test_icon_path_as_python_and_as_exe(tmp_path, monkeypatch):
|
|
assert viewer.icon_path() == PROJECT / "assets" / "icon.png"
|
|
assert not QIcon(str(viewer.icon_path())).isNull()
|
|
monkeypatch.setattr(sys, "frozen", True, raising=False)
|
|
monkeypatch.setattr(sys, "_MEIPASS", str(tmp_path), raising=False)
|
|
assert viewer.icon_path() == tmp_path / "assets" / "icon.png"
|
|
|
|
|
|
def test_version_is_three_numbers():
|
|
assert len(VERSION.split(".")) == 3 and all(n.isdigit() for n in VERSION.split("."))
|
|
|
|
|
|
def test_version_file_for_exe():
|
|
pytest.importorskip("PyInstaller") # build.py braucht PyInstaller (requirements-build.txt)
|
|
sys.path.insert(0, str(PROJECT))
|
|
import build
|
|
|
|
text = build.version_file_text()
|
|
ast.parse(text) # PyInstaller liest die Datei als Python-Ausdruck
|
|
major, minor, patch = (int(n) for n in VERSION.split("."))
|
|
assert f"filevers=({major}, {minor}, {patch}, 0)" in text
|
|
assert f"StringStruct('ProductName', {APP_NAME!r})" in text
|
|
assert f"StringStruct('LegalCopyright', {COPYRIGHT!r})" in text
|