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