blob: fb817193d5109501799e74ef0c8ed58843be76aa [file] [log] [blame]
Guido van Rossuma0f7e852000-07-01 01:13:31 +00001# Test to see if openpty works. (But don't worry if it isn't available.)
2
3import os
Fredrik Lundhf7850422001-01-17 21:51:36 +00004from test_support import verbose, TestFailed, TestSkipped
Guido van Rossuma0f7e852000-07-01 01:13:31 +00005
6try:
7 if verbose:
8 print "Calling os.openpty()"
9 master, slave = os.openpty()
10 if verbose:
11 print "(master, slave) = (%d, %d)"%(master, slave)
12except AttributeError:
Thomas Woutersb9fa0a82000-08-04 13:34:43 +000013 raise TestSkipped, "No openpty() available."
Guido van Rossuma0f7e852000-07-01 01:13:31 +000014
Thomas Woutersbaf26632000-07-19 14:51:54 +000015if not os.isatty(master):
16 raise TestFailed, "Master-end of pty is not a terminal."
17if not os.isatty(slave):
18 raise TestFailed, "Slave-end of pty is not a terminal."
Guido van Rossuma0f7e852000-07-01 01:13:31 +000019
20os.write(slave, 'Ping!')
21print os.read(master, 1024)