home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / pythonwin / python.exe / TEST_OPENPTY.PY < prev    next >
Encoding:
Python Source  |  2002-12-31  |  545 b   |  20 lines

  1. # Test to see if openpty works. (But don't worry if it isn't available.)
  2.  
  3. import os
  4. from test.test_support import verbose, TestFailed, TestSkipped
  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 TestSkipped, "No openpty() available."
  14.  
  15. if not os.isatty(slave):
  16.     raise TestFailed, "Slave-end of pty is not a terminal."
  17.  
  18. os.write(slave, 'Ping!')
  19. print os.read(master, 1024)
  20.