"""Run synthetic regressions against actual frozen listener/UI code from the EXE.""" from pathlib import Path import importlib.abc import importlib.util import runpy import sys from PyInstaller.archive.readers import CArchiveReader folder = Path(__file__).resolve().parent root = Path(r'C:\wechat_rpa') exe = root / 'dist/ZhenAI-WeCom-Assistant-v1.4.23/ZhenAI-WeCom-Assistant-v1.4.23.exe' pyz = CArchiveReader(str(exe)).open_embedded_archive('PYZ.pyz') modules = {'review_assistant', 'review_assistant_contacts', 'send_lock', 'protocol_engine', 'gui_runtime', 'wechat_gui_qt', 'wechat_bot', 'review_policy', 'review_state', 'reply_session_policy', 'desktop_instance', 'wechat_gui'} class FrozenListenerCode(importlib.abc.MetaPathFinder, importlib.abc.Loader): def find_spec(self, fullname, path=None, target=None): if fullname in modules: return importlib.util.spec_from_loader(fullname, self, origin=str(exe)) def create_module(self, spec): return None def exec_module(self, module): module.__file__ = str(root / (module.__name__ + '.py')) exec(pyz.extract(module.__name__), module.__dict__) sys.meta_path.insert(0, FrozenListenerCode()) runner = folder.parent / 'loading-performance-20260917/run_isolated.py' sys.argv = [str(runner), str(root), str(folder / 'frozen-continuity-tests.json'), 'test_review_assistant_contacts', 'test_review_assistant_ui', 'test_protocol_review_assistant', 'test_visual_review_assistant'] runpy.run_path(str(runner), run_name='__main__')