Skip to content

Commit 8be2fe5

Browse files
committed
DEBUGGING
Signed-off-by: Pablo Galindo <[email protected]>
1 parent 659556f commit 8be2fe5

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

Lib/test/test_remote_pdb.py

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ def _read_until_prompt(self, client_file):
328328
if not data:
329329
break
330330
msg = json.loads(data.decode())
331+
print(msg)
331332
messages.append(msg)
332333
if 'prompt' in msg:
333334
break
@@ -467,7 +468,7 @@ def bar():
467468
version=pdb._PdbServer.protocol_version(),
468469
)
469470
print("Connected to debugger")
470-
iterations = 10
471+
iterations = 60
471472
while iterations > 0:
472473
print("Iteration", iterations)
473474
time.sleep(1)
@@ -482,27 +483,36 @@ def bar():
482483

483484
with process:
484485

485-
# Skip initial messages until we get to the prompt
486-
self._read_until_prompt(client_file)
487-
488-
# Continue execution
489-
self._send_command(client_file, "c")
490-
491-
# Send keyboard interrupt signal
492-
self._send_command(client_file, json.dumps({"signal": "INT"}))
493-
self._send_interrupt(process.pid)
494-
messages = self._read_until_prompt(client_file)
486+
try:
495487

496-
# Verify we got the keyboard interrupt message
497-
interrupt_msg = next(msg['message'] for msg in messages if 'message' in msg)
498-
self.assertIn("bar()", interrupt_msg)
488+
# Skip initial messages until we get to the prompt
489+
self._read_until_prompt(client_file)
499490

500-
# Continue to end
501-
self._send_command(client_file, "iterations = 0")
502-
self._send_command(client_file, "c")
503-
stdout, _ = process.communicate(timeout=5)
504-
self.assertIn("Function returned: 42", stdout)
505-
self.assertEqual(process.returncode, 0)
491+
# Continue execution
492+
self._send_command(client_file, "c")
493+
494+
# Send keyboard interrupt signal
495+
self._send_command(client_file, json.dumps({"signal": "INT"}))
496+
self._send_interrupt(process.pid)
497+
messages = self._read_until_prompt(client_file)
498+
print(messages)
499+
500+
# Verify we got the keyboard interrupt message
501+
interrupt_msg = next(msg['message'] for msg in messages if 'message' in msg)
502+
self.assertIn("bar()", interrupt_msg)
503+
504+
# Continue to end
505+
self._send_command(client_file, "iterations = 0")
506+
self._send_command(client_file, "c")
507+
stdout, _ = process.communicate(timeout=5)
508+
self.assertIn("Function returned: 42", stdout)
509+
self.assertEqual(process.returncode, 0)
510+
511+
except Exception as e:
512+
stdout, stderr = process.communicate(timeout=5)
513+
print(stderr)
514+
print(stdout)
515+
raise e from None
506516

507517
def test_handle_eof(self):
508518
"""Test that EOF signal properly exits the debugger."""

0 commit comments

Comments
 (0)