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

Method test_breakpoints

Lib/test/test_remote_pdb.py:1165–1205  ·  view source on GitHub ↗

Test setting and hitting breakpoints.

(self)

Source from the content-addressed store, hash-verified

1163 self.assertEqual(process.returncode, 0)
1164
1165 def test_breakpoints(self):
1166 """Test setting and hitting breakpoints."""
1167 self._create_script()
1168 process, client_file = self._connect_and_get_client_file()
1169 with kill_on_error(process):
1170 # Skip initial messages until we get to the prompt
1171 self._read_until_prompt(client_file)
1172
1173 # Set a breakpoint at the return statement
1174 self._send_command(client_file, "break bar")
1175 messages = self._read_until_prompt(client_file)
1176 bp_msg = next(msg['message'] for msg in messages if 'message' in msg)
1177 self.assertIn("Breakpoint", bp_msg)
1178
1179 # Continue execution until breakpoint
1180 self._send_command(client_file, "c")
1181 messages = self._read_until_prompt(client_file)
1182
1183 # Verify we hit the breakpoint
1184 hit_msg = next(msg['message'] for msg in messages if 'message' in msg)
1185 self.assertIn("bar()", hit_msg)
1186
1187 # Check breakpoint list
1188 self._send_command(client_file, "b")
1189 messages = self._read_until_prompt(client_file)
1190 list_msg = next(msg['message'] for msg in reversed(messages) if 'message' in msg)
1191 self.assertIn("1 breakpoint", list_msg)
1192 self.assertIn("breakpoint already hit 1 time", list_msg)
1193
1194 # Clear breakpoint
1195 self._send_command(client_file, "clear 1")
1196 messages = self._read_until_prompt(client_file)
1197 clear_msg = next(msg['message'] for msg in reversed(messages) if 'message' in msg)
1198 self.assertIn("Deleted breakpoint", clear_msg)
1199
1200 # Continue to end
1201 self._send_command(client_file, "c")
1202 stdout, _ = process.communicate(timeout=SHORT_TIMEOUT)
1203
1204 self.assertIn("Function returned: 42", stdout)
1205 self.assertEqual(process.returncode, 0)
1206
1207 def test_keyboard_interrupt(self):
1208 """Test that sending keyboard interrupt breaks into pdb."""

Callers

nothing calls this directly

Calls 8

_create_scriptMethod · 0.95
_read_until_promptMethod · 0.95
_send_commandMethod · 0.95
assertInMethod · 0.80
kill_on_errorFunction · 0.70
communicateMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected