(root)/
Python-3.11.7/
Lib/
test/
test_openpty.py
       1  # Test to see if openpty works. (But don't worry if it isn't available.)
       2  
       3  import os, unittest
       4  
       5  if not hasattr(os, "openpty"):
       6      raise unittest.SkipTest("os.openpty() not available.")
       7  
       8  
       9  class ESC[4;38;5;81mOpenptyTest(ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      10      def test(self):
      11          master, slave = os.openpty()
      12          self.addCleanup(os.close, master)
      13          self.addCleanup(os.close, slave)
      14          if not os.isatty(slave):
      15              self.fail("Slave-end of pty is not a terminal.")
      16  
      17          os.write(slave, b'Ping!')
      18          self.assertEqual(os.read(master, 1024), b'Ping!')
      19  
      20  if __name__ == '__main__':
      21      unittest.main()