2000-06-30 22:13:31 -03:00
|
|
|
# Test to see if openpty works. (But don't worry if it isn't available.)
|
|
|
|
|
2006-10-29 16:31:17 -04:00
|
|
|
import os, unittest
|
2009-03-26 17:48:25 -03:00
|
|
|
from test.test_support import run_unittest, SkipTest
|
2000-06-30 22:13:31 -03:00
|
|
|
|
2006-10-29 17:54:18 -04:00
|
|
|
if not hasattr(os, "openpty"):
|
2009-03-26 17:48:25 -03:00
|
|
|
raise SkipTest, "No openpty() available."
|
2006-10-29 17:54:18 -04:00
|
|
|
|
|
|
|
|
2006-10-29 16:31:17 -04:00
|
|
|
class OpenptyTest(unittest.TestCase):
|
|
|
|
def test(self):
|
2006-10-29 17:54:18 -04:00
|
|
|
master, slave = os.openpty()
|
2006-10-29 16:31:17 -04:00
|
|
|
if not os.isatty(slave):
|
|
|
|
self.fail("Slave-end of pty is not a terminal.")
|
2000-06-30 22:13:31 -03:00
|
|
|
|
2006-10-29 16:31:17 -04:00
|
|
|
os.write(slave, 'Ping!')
|
|
|
|
self.assertEqual(os.read(master, 1024), 'Ping!')
|
|
|
|
|
|
|
|
def test_main():
|
|
|
|
run_unittest(OpenptyTest)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
test_main()
|