LEFT | RIGHT |
1 from test.support import verbose, run_unittest, import_module | 1 from test.support import verbose, run_unittest, import_module |
2 | 2 |
3 #Skip these tests if either fcntl or termios is not available | 3 #Skip these tests if either fcntl or termios is not available |
4 fcntl = import_module('fcntl') | 4 fcntl = import_module('fcntl') |
5 import_module('termios') | 5 import_module('termios') |
6 | 6 |
7 import errno | 7 import errno |
8 import pty | 8 import pty |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 except OSError as e: | 90 except OSError as e: |
91 if e.errno != errno.EAGAIN: | 91 if e.errno != errno.EAGAIN: |
92 raise | 92 raise |
93 # Restore the original flags. | 93 # Restore the original flags. |
94 fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags) | 94 fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags) |
95 | 95 |
96 debug("Writing to slave_fd") | 96 debug("Writing to slave_fd") |
97 os.write(slave_fd, TEST_STRING_1) | 97 os.write(slave_fd, TEST_STRING_1) |
98 s1 = os.read(master_fd, 1024) | 98 s1 = os.read(master_fd, 1024) |
99 self.assertEqual(b'I wish to buy a fish license.\n', | 99 self.assertEqual(b'I wish to buy a fish license.\n', |
100 normalize_output(s1)) | 100 normalize_output(s1)) |
101 | 101 |
102 debug("Writing chunked output") | 102 debug("Writing chunked output") |
103 os.write(slave_fd, TEST_STRING_2[:5]) | 103 os.write(slave_fd, TEST_STRING_2[:5]) |
104 os.write(slave_fd, TEST_STRING_2[5:]) | 104 os.write(slave_fd, TEST_STRING_2[5:]) |
105 s2 = os.read(master_fd, 1024) | 105 s2 = os.read(master_fd, 1024) |
106 self.assertEqual(b'For my pet fish, Eric.\n', normalize_output(s2)) | 106 self.assertEqual(b'For my pet fish, Eric.\n', normalize_output(s2)) |
107 | 107 |
108 os.close(slave_fd) | 108 os.close(slave_fd) |
109 os.close(master_fd) | 109 os.close(master_fd) |
110 | 110 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 192 |
193 os.close(master_fd) | 193 os.close(master_fd) |
194 | 194 |
195 # pty.fork() passed. | 195 # pty.fork() passed. |
196 | 196 |
197 def test_main(verbose=None): | 197 def test_main(verbose=None): |
198 run_unittest(PtyTest) | 198 run_unittest(PtyTest) |
199 | 199 |
200 if __name__ == "__main__": | 200 if __name__ == "__main__": |
201 test_main() | 201 test_main() |
LEFT | RIGHT |