home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 July / maximum-cd-2011-07.iso / DiscContents / LibO_3.3.2_Win_x86_install_multi.exe / libreoffice1.cab / test_openpty.py < prev    next >
Encoding:
Python Source  |  2011-03-15  |  605 b   |  24 lines

  1. # Test to see if openpty works. (But don't worry if it isn't available.)
  2.  
  3. import os, unittest
  4. from test.test_support import run_unittest, TestSkipped
  5.  
  6. if not hasattr(os, "openpty"):
  7.     raise TestSkipped, "No openpty() available."
  8.  
  9.  
  10. class OpenptyTest(unittest.TestCase):
  11.     def test(self):
  12.         master, slave = os.openpty()
  13.         if not os.isatty(slave):
  14.             self.fail("Slave-end of pty is not a terminal.")
  15.  
  16.         os.write(slave, 'Ping!')
  17.         self.assertEqual(os.read(master, 1024), 'Ping!')
  18.  
  19. def test_main():
  20.     run_unittest(OpenptyTest)
  21.  
  22. if __name__ == '__main__':
  23.     test_main()
  24.