Skip to main content
Glama
test_debugger_continue.py3.87 kB
""" Unit tests for debugger continue functionality. Tests execution continuation to next breakpoint. """ import tempfile from pathlib import Path from mcp_debug_tool.debugger import DebugController class TestDebuggerContinue: """Tests for continuing to next breakpoint.""" def test_continue_without_prior_run(self): """Test that continue fails if called without prior run_to_breakpoint.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: f.write("x = 1\ny = 2\n") script_path = Path(f.name) try: debugger = DebugController() # Try to continue without running first response, _ = debugger.continue_execution(str(script_path), 2) assert response.hit is False assert response.error is not None assert "No active execution context" in response.error.message finally: script_path.unlink() def test_continue_error_on_exception(self): """Test continue when exception occurs.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: f.write(""" x = 1 # Line 2 - first breakpoint y = 1 / 0 # Line 3 - exception z = 2 # Line 4 - second breakpoint (not reached) """) script_path = Path(f.name) try: debugger = DebugController() # Run to first breakpoint response1 = debugger.run_to_breakpoint(script_path, str(script_path), 2) assert response1.hit is True # Continue - should encounter exception response2, debugger = debugger.continue_execution(str(script_path), 4) assert response2.hit is False assert response2.error is not None assert "ZeroDivisionError" in response2.error.type finally: script_path.unlink() def test_continue_preserves_globals(self): """Test that continue preserves global state from first execution.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: f.write(""" x = 1 # Line 2 - first breakpoint y = 2 # Line 3 """) script_path = Path(f.name) try: debugger = DebugController() # Run to first line response1 = debugger.run_to_breakpoint(script_path, str(script_path), 2) assert response1.hit is True # Globals should be populated assert debugger.globals_dict is not None assert len(debugger.globals_dict) > 0 # Continue call should have access to globals response2, debugger = debugger.continue_execution(str(script_path), 3) # Note: May not hit depending on actual line execution finally: script_path.unlink() def test_continue_response_structure(self): """Test that continue response has correct structure.""" with tempfile.NamedTemporaryFile(mode="w", suffix=".py", delete=False) as f: f.write(""" a = 1 # Line 2 - first breakpoint b = 2 """) script_path = Path(f.name) try: debugger = DebugController() # Run to first breakpoint response1 = debugger.run_to_breakpoint(script_path, str(script_path), 2) assert response1.hit is True # Continue should return proper ContinueResponse response2, debugger = debugger.continue_execution(str(script_path), 3) # Response should have all required fields assert hasattr(response2, 'hit') assert hasattr(response2, 'completed') assert hasattr(response2, 'frameInfo') assert hasattr(response2, 'locals') assert hasattr(response2, 'error') finally: script_path.unlink()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Kaina3/Debug-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server