import contextlib import io import os import shutil import struct import tempfile import unittest from helpers import FIXTURE, HAVE_PIL, bitwise_word_crc from nxhmi import cli, tft def fake_tft(payload: bytes) -> bytes: """A synthetic .tft-shaped blob: layout table + trailer CRC computed the way the trailer behaves (word-per-byte CRC whose stream ends at the trailer). Real .tft files cannot be used in tests: they contain Nextion's firmware.""" head = bytearray(0x200) struct.pack_into("