"""scripts/play-linux.sh answers --help with its usage, without a game executable, Wine or a prefix. python -I tests/test_play_linux.py The help path is checked alone: PATH holds nothing but the shell, and no LEONIDA_* variable is set, so a --help that fell through to the game start would fail loudly instead of passing. POSIX only; no game files. """ import os import shutil import subprocess import unittest from pathlib import Path SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "play-linux.sh" @unittest.skipUnless(os.name == "posix" and shutil.which("sh"), "needs a POSIX shell") class PlayLinuxHelp(unittest.TestCase): def run_help(self, flag: str) -> subprocess.CompletedProcess: return subprocess.run(["sh", str(SCRIPT), flag], env={"PATH": "/usr/bin:/bin"}, capture_output=True, text=True, timeout=60) def test_help_prints_the_usage_and_starts_nothing(self): for flag in ("-h", "--help"): with self.subTest(flag=flag): p = self.run_help(flag) self.assertEqual(p.returncode, 0, p.stderr) self.assertIn("usage:", p.stdout) self.assertIn("--series-x", p.stdout) self.assertEqual(p.stderr, "") if __name__ == "__main__": unittest.main()