PageRenderTime 40ms CodeModel.GetById 36ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/Lib/test/test_openpty.py

http://unladen-swallow.googlecode.com/
Python | 23 lines | 15 code | 7 blank | 1 comment | 5 complexity | 2f93d2c9c468b99c84c5d3cdef1a37ea MD5 | raw file
 1# Test to see if openpty works. (But don't worry if it isn't available.)
 2
 3import os, unittest
 4from test.test_support import run_unittest, TestSkipped
 5
 6if not hasattr(os, "openpty"):
 7    raise TestSkipped, "No openpty() available."
 8
 9
10class 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
19def test_main():
20    run_unittest(OpenptyTest)
21
22if __name__ == '__main__':
23    test_main()