Staging
v0.5.1
https://github.com/python/cpython
Raw File
Tip revision: 4aa13dfa7f60178366775ca4bfd9c76d89229125 authored by cvs2svn on 13 June 2001, 19:26:00 UTC
This commit was manufactured by cvs2svn to create tag 'r201c1'.
Tip revision: 4aa13df
test_openpty.py
# Test to see if openpty works. (But don't worry if it isn't available.)

import os
from test_support import verbose, TestFailed, TestSkipped

try:
    if verbose:
        print "Calling os.openpty()"
    master, slave = os.openpty()
    if verbose:
        print "(master, slave) = (%d, %d)"%(master, slave)
except AttributeError:
    raise TestSkipped, "No openpty() available."

if not os.isatty(master):
    raise TestFailed, "Master-end of pty is not a terminal."
if not os.isatty(slave):
    raise TestFailed, "Slave-end of pty is not a terminal."

os.write(slave, 'Ping!')
print os.read(master, 1024)

back to top