tts-voice-creator-clone-and.../tests/test_guided_installer.py
2026-10-04 19:28:37 +02:00

32 lines
959 B
Python

import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
try:
from guided_installer import run_command
except ImportError: # no tkinter on this host
run_command = None
@unittest.skipIf(run_command is None, "tkinter unavailable")
class RunCommandTest(unittest.TestCase):
def test_success_logs_output(self):
out = []
self.assertTrue(run_command([sys.executable, "-c", "print('hi')"], out.append))
self.assertIn("hi", "".join(out))
def test_nonzero_exit(self):
out = []
self.assertFalse(run_command([sys.executable, "-c", "raise SystemExit(3)"], out.append))
self.assertIn("exited with 3", out[-1])
def test_missing_binary(self):
out = []
self.assertFalse(run_command(["/nonexistent-binary-xyz"], out.append))
self.assertTrue(out[0].startswith("Failed:"))
if __name__ == "__main__":
unittest.main()