ยปCore Development>Code coverage>Lib/test/test_openpty.py

Python code coverage for Lib/test/test_openpty.py

#countcontent
1n/a# Test to see if openpty works. (But don't worry if it isn't available.)
2n/a
3n/aimport os, unittest
4n/a
5n/aif not hasattr(os, "openpty"):
6n/a raise unittest.SkipTest("os.openpty() not available.")
7n/a
8n/a
9n/aclass OpenptyTest(unittest.TestCase):
10n/a def test(self):
11n/a master, slave = os.openpty()
12n/a self.addCleanup(os.close, master)
13n/a self.addCleanup(os.close, slave)
14n/a if not os.isatty(slave):
15n/a self.fail("Slave-end of pty is not a terminal.")
16n/a
17n/a os.write(slave, b'Ping!')
18n/a self.assertEqual(os.read(master, 1024), b'Ping!')
19n/a
20n/aif __name__ == '__main__':
21n/a unittest.main()