예제 #1
0
def test_debug_on_bootstrap_remove_invalid_breaks():
    """
    Sometimes it's possible for a marker to end up on a line that is eventually
    an in-valid breakpoint line. This checks that such markers don't end up
    with an attempt to set a breakpoint and are ultimately discarded so the
    visual state of the markers matches the breakpoint state of the debugger.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.breakpoint_handles = set([
        0,
    ])
    mock_tab.markerLine.return_value = 1
    view.widgets = [
        mock_tab,
    ]
    with mock.patch('mu.modes.debugger.is_breakpoint_line',
                    return_value=False):
        dm.debug_on_bootstrap()
    assert 0 not in mock_tab.breakpoint_handles
    mock_tab.markerDelete.assert_called_once_with(1, -1)
예제 #2
0
def test_debug_on_bootstrap():
    """
    Ensure all the current breakpoints are set and the script is run.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.breakpoint_lines = set([0, ])
    view.widgets = [mock_tab, ]
    dm.debug_on_bootstrap()
    dm.debugger.create_breakpoint.assert_called_once_with(mock_tab.path, 1)
    dm.debugger.do_run.assert_called_once_with()
예제 #3
0
파일: test_debug.py 프로젝트: willingc/mu
def test_debug_on_bootstrap():
    """
    Ensure all the current breakpoints are set and the script is run.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.breakpoint_lines = set([0, ])
    view.widgets = [mock_tab, ]
    dm.debug_on_bootstrap()
    dm.debugger.create_breakpoint.assert_called_once_with(mock_tab.path, 1)
    dm.debugger.do_run.assert_called_once_with()
예제 #4
0
def test_debug_on_bootstrap_remove_missing_marker_handles():
    """
    Ensure all marker handles that are not currently associated with a line
    are removed from the breakpoint_handles set.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = "foo"
    mock_tab.breakpoint_handles = set([0])
    mock_tab.markerLine.return_value = -1
    view.widgets = [mock_tab]
    dm.debug_on_bootstrap()
    assert dm.debugger.create_breakpoint.call_count == 0
    assert 0 not in mock_tab.breakpoint_handles
예제 #5
0
def test_debug_on_bootstrap():
    """
    Ensure all the current breakpoints are set and the script is run.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = "foo"
    mock_tab.text.return_value = "print('Hello')"
    mock_tab.breakpoint_handles = set([0])
    mock_tab.markerLine.return_value = 0
    view.widgets = [mock_tab]
    dm.debug_on_bootstrap()
    dm.debugger.create_breakpoint.assert_called_once_with(mock_tab.path, 1)
    dm.debugger.do_run.assert_called_once_with()
예제 #6
0
def test_debug_on_bootstrap_remove_missing_marker_handles():
    """
    Ensure all marker handles that are not currently associated with a line
    are removed from the breakpoint_handles set.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.breakpoint_handles = set([0, ])
    mock_tab.markerLine.return_value = -1
    view.widgets = [mock_tab, ]
    dm.debug_on_bootstrap()
    assert dm.debugger.create_breakpoint.call_count == 0
    assert 0 not in mock_tab.breakpoint_handles
예제 #7
0
def test_debug_on_bootstrap():
    """
    Ensure all the current breakpoints are set and the script is run.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.text.return_value = "print('Hello')"
    mock_tab.breakpoint_handles = set([0, ])
    mock_tab.markerLine.return_value = 0
    view.widgets = [mock_tab, ]
    dm.debug_on_bootstrap()
    dm.debugger.create_breakpoint.assert_called_once_with(mock_tab.path, 1)
    dm.debugger.do_run.assert_called_once_with()
예제 #8
0
def test_debug_on_bootstrap_ignore_duplicate_handles():
    """
    Sometimes it's possible for two different handles to be found on a single
    line due to how Scintilla moves markers around as lines are concatenated.
    This ensures only one breakpoint is created per marker.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = "foo"
    mock_tab.text.return_value = "print('Hello')"
    mock_tab.breakpoint_handles = set([0, 1])
    mock_tab.markerLine.side_effect = [1, 1]
    view.widgets = [mock_tab]
    dm.debug_on_bootstrap()
    assert dm.debugger.create_breakpoint.call_count == 1
예제 #9
0
def test_debug_on_bootstrap_ignore_duplicate_handles():
    """
    Sometimes it's possible for two different handles to be found on a single
    line due to how Scintilla moves markers around as lines are concatenated.
    This ensures only one breakpoint is created per marker.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.text.return_value = "print('Hello')"
    mock_tab.breakpoint_handles = set([0, 1])
    mock_tab.markerLine.side_effect = [1, 1]
    view.widgets = [mock_tab, ]
    dm.debug_on_bootstrap()
    assert dm.debugger.create_breakpoint.call_count == 1
예제 #10
0
def test_debug_on_bootstrap_remove_invalid_breaks():
    """
    Sometimes it's possible for a marker to end up on a line that is eventually
    an in-valid breakpoint line. This checks that such markers don't end up
    with an attempt to set a breakpoint and are ultimately discarded so the
    visual state of the markers matches the breakpoint state of the debugger.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    mock_tab = mock.MagicMock()
    mock_tab.path = 'foo'
    mock_tab.breakpoint_handles = set([0, ])
    mock_tab.markerLine.return_value = 1
    view.widgets = [mock_tab, ]
    with mock.patch('mu.modes.debugger.is_breakpoint_line',
                    return_value=False):
        dm.debug_on_bootstrap()
    assert 0 not in mock_tab.breakpoint_handles
    mock_tab.markerDelete.assert_called_once_with(1, -1)