(self)
| 301 | |
| 302 | @unittest.skip('TODO: RUSTPYTHON; AttributeError: module "tty" has no attribute "tcgetwinsize"') |
| 303 | def test_spawn_doesnt_hang(self): |
| 304 | self.addCleanup(unlink, TESTFN) |
| 305 | with open(TESTFN, 'wb') as f: |
| 306 | STDOUT_FILENO = 1 |
| 307 | dup_stdout = os.dup(STDOUT_FILENO) |
| 308 | os.dup2(f.fileno(), STDOUT_FILENO) |
| 309 | buf = b'' |
| 310 | def master_read(fd): |
| 311 | nonlocal buf |
| 312 | data = os.read(fd, 1024) |
| 313 | buf += data |
| 314 | return data |
| 315 | try: |
| 316 | pty.spawn([sys.executable, '-c', 'print("hi there")'], |
| 317 | master_read) |
| 318 | finally: |
| 319 | os.dup2(dup_stdout, STDOUT_FILENO) |
| 320 | os.close(dup_stdout) |
| 321 | self.assertEqual(buf, b'hi there\r\n') |
| 322 | with open(TESTFN, 'rb') as f: |
| 323 | self.assertEqual(f.read(), b'hi there\r\n') |
| 324 | |
| 325 | class SmallPtyTests(unittest.TestCase): |
| 326 | """These tests don't spawn children or hang.""" |
nothing calls this directly
no test coverage detected