def test_debug_on_breakpoint_enable(): """ Handle the signal that shows the debug runner has created a breakpoint. """ editor = mock.MagicMock() view = mock.MagicMock() mock_tab = mock.MagicMock() view.current_tab = mock_tab dm = DebugMode(editor, view) mock_breakpoint = mock.MagicMock() mock_breakpoint.line = 1 dm.debug_on_breakpoint_enable(mock_breakpoint) mock_tab.markerAdd.assert_called_once_with(mock_breakpoint.line - 1, mock_tab.BREAKPOINT_MARKER)
def test_debug_on_breakpoint_enable_marker_already_exists(): """ Handle the signal that shows the debug runner has created a breakpoint during the bootstrapping of the debug runner, so it doesn't add a second marker at the same location as the pre-existing one that caused the breakpoint to be created during bootstrapping. """ editor = mock.MagicMock() view = mock.MagicMock() mock_tab = mock.MagicMock() mock_tab.markersAtLine.return_value = True view.current_tab = mock_tab dm = DebugMode(editor, view) mock_breakpoint = mock.MagicMock() mock_breakpoint.line = 1 dm.debug_on_breakpoint_enable(mock_breakpoint) mock_tab.markerAdd.call_count == 0
def test_debug_on_breakpoint_enable_different_tab(): """ When the breakpoints are set on bootstrap, some of them may be for tabs that are not the currently visible tab. In any case, when breakpoints are set "on_breakpoint_enable" is called. This check ensures the marker is only created IF the current tab has the same path as the filename associated with the newly created breakpoint. """ editor = mock.MagicMock() view = mock.MagicMock() mock_tab = mock.MagicMock() mock_tab.markersAtLine.return_value = False mock_tab.path = "foo" view.current_tab = mock_tab dm = DebugMode(editor, view) mock_breakpoint = mock.MagicMock() mock_breakpoint.filename = "bar" mock_breakpoint.line = 1 dm.debug_on_breakpoint_enable(mock_breakpoint) assert mock_tab.markerAdd.call_count == 0
def test_debug_on_breakpoint_enable_different_tab(): """ When the breakpoints are set on bootstrap, some of them may be for tabs that are not the currently visible tab. In any case, when breakpoints are set "on_breakpoint_enable" is called. This check ensures the marker is only created IF the current tab has the same path as the filename associated with the newly created breakpoint. """ editor = mock.MagicMock() view = mock.MagicMock() mock_tab = mock.MagicMock() mock_tab.markersAtLine.return_value = False mock_tab.path = 'foo' view.current_tab = mock_tab dm = DebugMode(editor, view) mock_breakpoint = mock.MagicMock() mock_breakpoint.filename = 'bar' mock_breakpoint.line = 1 dm.debug_on_breakpoint_enable(mock_breakpoint) assert mock_tab.markerAdd.call_count == 0