home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / TEST_OPENPTY.PY < prev    next >
Encoding:
Python Source  |  2000-09-28  |  631 b   |  23 lines

  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, 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(master):
  16.     raise TestFailed, "Master-end of pty is not a terminal."
  17. if not os.isatty(slave):
  18.     raise TestFailed, "Slave-end of pty is not a terminal."
  19.  
  20. os.write(slave, 'Ping!')
  21. print os.read(master, 1024)
  22.  
  23.