34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""Guard against the PyInstaller entry-point regression.
|
|
|
|
If the bundled entry script runs as ``__main__`` and uses relative imports, it dies
|
|
with "attempted relative import with no known parent package". We run the launcher
|
|
the same way PyInstaller does — as a top-level script — and assert it boots and
|
|
exits cleanly via the self-test hook.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
LAUNCHER = REPO_ROOT / "packaging" / "suite_launcher.py"
|
|
|
|
|
|
def test_launcher_boots_as_script_without_import_error():
|
|
env = {**os.environ, "SUITE_SELFTEST": "1", "QT_QPA_PLATFORM": "offscreen"}
|
|
# Run from a neutral cwd so success depends on the package being importable,
|
|
# not on the current directory.
|
|
proc = subprocess.run(
|
|
[sys.executable, str(LAUNCHER), "--module", "da12", "--simulate"],
|
|
cwd=str(REPO_ROOT / "packaging"),
|
|
env=env,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=60,
|
|
)
|
|
assert "attempted relative import" not in proc.stderr.lower(), proc.stderr
|
|
assert proc.returncode == 0, f"stdout={proc.stdout}\nstderr={proc.stderr}"
|