MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_spawn_doesnt_hang

Method test_spawn_doesnt_hang

Lib/test/test_pty.py:303–323  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
325class SmallPtyTests(unittest.TestCase):
326 """These tests don't spawn children or hang."""

Callers

nothing calls this directly

Calls 8

addCleanupMethod · 0.80
spawnMethod · 0.80
openFunction · 0.50
dupMethod · 0.45
filenoMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected