MCPcopy Index your code
hub / github.com/python/cpython / do_integration_test

Method do_integration_test

Lib/test/test_remote_pdb.py:1541–1598  ·  view source on GitHub ↗
(self, client_stdin)

Source from the content-addressed store, hash-verified

1539 pass
1540
1541 def do_integration_test(self, client_stdin):
1542 process = subprocess.Popen(
1543 [sys.executable, self.script_path],
1544 stdout=subprocess.PIPE,
1545 stderr=subprocess.PIPE,
1546 text=True
1547 )
1548 self.addCleanup(process.stdout.close)
1549 self.addCleanup(process.stderr.close)
1550
1551 # Wait for the process to reach our attachment point
1552 self.sock.settimeout(10)
1553 conn, _ = self.sock.accept()
1554 conn.close()
1555
1556 client_stdin = io.StringIO(client_stdin)
1557 client_stdout = io.StringIO()
1558 client_stderr = io.StringIO()
1559
1560 self.addCleanup(client_stdin.close)
1561 self.addCleanup(client_stdout.close)
1562 self.addCleanup(client_stderr.close)
1563 self.addCleanup(process.wait)
1564
1565 with (
1566 unittest.mock.patch("sys.stdin", client_stdin),
1567 redirect_stdout(client_stdout),
1568 redirect_stderr(client_stderr),
1569 unittest.mock.patch("sys.argv", ["pdb", "-p", str(process.pid)]),
1570 unittest.mock.patch(
1571 "pdb.exit_with_permission_help_text", side_effect=PermissionError
1572 ),
1573 ):
1574 try:
1575 pdb.main()
1576 except PermissionError:
1577 self.skipTest("Insufficient permissions for remote execution")
1578
1579 process.wait()
1580 server_stdout = process.stdout.read()
1581 server_stderr = process.stderr.read()
1582
1583 if process.returncode != 0:
1584 print("server failed")
1585 print(f"server stdout:\n{server_stdout}")
1586 print(f"server stderr:\n{server_stderr}")
1587
1588 self.assertEqual(process.returncode, 0)
1589 return {
1590 "client": {
1591 "stdout": client_stdout.getvalue(),
1592 "stderr": client_stderr.getvalue(),
1593 },
1594 "server": {
1595 "stdout": server_stdout,
1596 "stderr": server_stderr,
1597 },
1598 }

Calls 13

waitMethod · 0.95
getvalueMethod · 0.95
redirect_stdoutClass · 0.90
redirect_stderrClass · 0.90
strFunction · 0.85
addCleanupMethod · 0.80
skipTestMethod · 0.80
settimeoutMethod · 0.45
acceptMethod · 0.45
closeMethod · 0.45
mainMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected