"""Tests for the host PTY session (M12 Tier 3).""" import time import unittest from rigdoctor.core.pty_session import PtySession class PtySessionTests(unittest.TestCase): def test_runs_command_and_reads_output(self): pty = PtySession(rows=24, cols=80) try: time.sleep(0.4) pty.read() # drain the shell prompt pty.write(b"echo PTY_MARKER_42\n") deadline = time.time() + 3 buf = "" while time.time() < deadline and "PTY_MARKER_42" not in buf: time.sleep(0.1) buf += pty.read().decode(errors="replace") self.assertIn("PTY_MARKER_42", buf) finally: pty.close() if __name__ == "__main__": unittest.main()