from __future__ import annotations from pathlib import Path def _assert_bootstrap_before(path: str, *late_markers: str) -> None: text = Path(path).read_text(encoding="utf-8") import_marker = "from douyin.updater.bootstrap import run_startup_update_check_early" call_marker = "run_startup_update_check_early(" assert import_marker in text assert call_marker in text call_index = text.index(call_marker) for marker in late_markers: assert marker in text assert call_index < text.index(marker) def test_run_cli_runs_update_bootstrap_before_heavy_imports(): _assert_bootstrap_before( "bin/run_cli.py", "from douyin.core.douyin_fudai import fudai_analyse", "from douyin.license.license_manager import require_license_or_exit", ) def test_gui_app_runs_update_bootstrap_before_gui_imports(): _assert_bootstrap_before( "gui/gui_app.py", "from gui.gui_core import", "from douyin.license.license_manager import require_license_or_exit", ) def test_web_gui_runs_update_bootstrap_before_gui_imports(): _assert_bootstrap_before( "gui/web_gui.py", "from douyin.core import path_config", "from douyin.license.license_manager import require_license_or_exit", )