Guido van Rossum | a0f7e85 | 2000-07-01 01:13:31 +0000 | [diff] [blame] | 1 | # Test to see if openpty works. (But don't worry if it isn't available.) |
| 2 | |
| 3 | import os |
| 4 | from test_support import verbose, TestFailed |
| 5 | |
| 6 | try: |
| 7 | if verbose: |
| 8 | print "Calling os.openpty()" |
| 9 | master, slave = os.openpty() |
| 10 | if verbose: |
| 11 | print "(master, slave) = (%d, %d)"%(master, slave) |
| 12 | except AttributeError: |
| 13 | raise ImportError, "No openpty() available." |
| 14 | |
| 15 | ## # Please uncomment these if os.isatty() is added. |
| 16 | ## if not os.isatty(master): |
| 17 | ## raise TestFailed, "Master-end of pty is not a terminal." |
| 18 | ## if not os.isatty(slave): |
| 19 | ## raise TestFailed, "Slave-end of pty is not a terminal." |
| 20 | |
| 21 | os.write(slave, 'Ping!') |
| 22 | print os.read(master, 1024) |
| 23 | |