• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python debugger.DebugMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mu.modes.debugger.DebugMode的典型用法代码示例。如果您正苦于以下问题:Python DebugMode类的具体用法?Python DebugMode怎么用?Python DebugMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DebugMode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_debug_on_stack

def test_debug_on_stack():
    """
    Ensure the expected locals dict is passed to the view so the object
    inspector is updated properly.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    stack = [
        (
            1,
            {
                'locals': {
                    'a': 'frame1',
                    'b': 'frame1',
                }
            }
        ),
        (
            2,
            {
                'locals': {
                    'b': 'frame2',
                    'c': 'frame2',
                }
            }
        )
    ]
    dm.debug_on_stack(stack)
    view.update_debug_inspector.assert_called_once_with({
        'a': 'frame1',
        'b': 'frame2',
        'c': 'frame2',
    })
开发者ID:ZanderBrown,项目名称:mu,代码行数:34,代码来源:test_debug.py


示例2: test_debug_start

def test_debug_start():
    """
    Ensure the handling of starting the debugger works as expected.
    """
    editor = mock.MagicMock()
    editor.envars = [['name', 'value'], ]
    view = mock.MagicMock()
    view.current_tab.path = '/foo'
    view.current_tab.isModified.return_value = True
    mock_runner = mock.MagicMock()
    view.add_python3_runner.return_value = mock_runner
    mock_debugger = mock.MagicMock()
    mock_debugger_class = mock.MagicMock(return_value=mock_debugger)
    dm = DebugMode(editor, view)
    dm.workspace_dir = mock.MagicMock(return_value='/bar')
    with mock.patch('builtins.open') as oa, \
            mock.patch('mu.modes.debugger.Debugger', mock_debugger_class), \
            mock.patch('mu.modes.debugger.write_and_flush'):
        dm.start()
        oa.assert_called_once_with('/foo', 'w', newline='')
    view.add_python3_runner.assert_called_once_with('/foo', '/bar',
                                                    debugger=True,
                                                    envars=[['name', 'value']])
    mock_runner.process.waitForStarted.assert_called_once_with()
    mock_runner.process.finished.connect.assert_called_once_with(dm.finished)
    view.add_debug_inspector.assert_called_once_with()
    view.set_read_only.assert_called_once_with(True)
    mock_debugger_class.assert_called_once_with('localhost', DEBUGGER_PORT,
                                                proc=mock_runner.process)
    assert dm.runner == mock_runner
    assert dm.debugger == mock_debugger
    assert mock_debugger.view == dm
    mock_debugger.start.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:33,代码来源:test_debug.py


示例3: test_debug_mode

def test_debug_mode():
    """
    Sanity check for setting up of the mode.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    assert dm.name == 'Graphical Debugger'
    assert dm.description is not None
    assert dm.icon == 'python'
    assert dm.runner is None
    assert dm.is_debugger is True
    assert dm.editor == editor
    assert dm.view == view

    assert dm.api() == []

    actions = dm.actions()
    assert len(actions) == 5
    assert actions[0]['name'] == 'stop'
    assert actions[0]['handler'] == dm.button_stop
    assert actions[1]['name'] == 'run'
    assert actions[1]['handler'] == dm.button_continue
    assert actions[2]['name'] == 'step-over'
    assert actions[2]['handler'] == dm.button_step_over
    assert actions[3]['name'] == 'step-in'
    assert actions[3]['handler'] == dm.button_step_in
    assert actions[4]['name'] == 'step-out'
    assert actions[4]['handler'] == dm.button_step_out
开发者ID:ZanderBrown,项目名称:mu,代码行数:29,代码来源:test_debug.py


示例4: test_debug_on_breakpoint_clear

def test_debug_on_breakpoint_clear():
    """
    Should do nothing.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    assert dm.debug_on_breakpoint_clear(None) is None
开发者ID:ZanderBrown,项目名称:mu,代码行数:8,代码来源:test_debug.py


示例5: test_debug_on_exception

def test_debug_on_exception():
    """
    Should do nothing.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    assert dm.debug_on_exception(None, None) is None
开发者ID:willingc,项目名称:mu,代码行数:8,代码来源:test_debug.py


示例6: test_debug_on_restart

def test_debug_on_restart():
    """
    Should do nothing.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    assert dm.debug_on_restart() is None
开发者ID:ZanderBrown,项目名称:mu,代码行数:8,代码来源:test_debug.py


示例7: test_debug_button_stop

def test_debug_button_stop():
    """
    Ensure the stop method is called when the stop button is clicked.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.stop = mock.MagicMock()
    dm.button_stop(None)
    dm.stop.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例8: test_debug_button_step_out

def test_debug_button_step_out():
    """
    Ensure the do_return method is called when the step-out button is clicked.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.button_step_out(None)
    dm.debugger.do_return.assert_called_once_with()
开发者ID:willingc,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例9: test_debug_on_line_ignore_file

def test_debug_on_line_ignore_file():
    """
    If the filename is in the ignored bucket, do a return.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.debug_on_line('bdb.py', 100)
    dm.debugger.do_return.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例10: test_debug_on_error

def test_debug_on_error():
    """
    Error messages result in a status message being shown by the editor.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debug_on_error('message')
    expected = 'Debugger error: message'
    editor.show_status_message.assert_called_once_with(expected)
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例11: test_debug_on_call

def test_debug_on_call():
    """
    Calling a function causes the debugger to step into the function.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.debug_on_call(None)
    dm.debugger.do_step.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例12: test_debug_on_return

def test_debug_on_return():
    """
    Returning from a function causes the debugger to step out of the function.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.debug_on_return(None)
    dm.debugger.do_step.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例13: test_debug_on_finished

def test_debug_on_finished():
    """
    When the debugger is finished, the view is reset.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.finished = mock.MagicMock()
    dm.debug_on_finished()
    dm.finished.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例14: test_debug_button_continue

def test_debug_button_continue():
    """
    Ensure the do_run method is called when the continue button is clicked.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.button_continue(None)
    dm.debugger.do_run.assert_called_once_with()
开发者ID:willingc,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例15: test_debug_start_no_tab

def test_debug_start_no_tab():
    """
    If there's no active tab, there can be no runner either.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab = None
    dm = DebugMode(editor, view)
    dm.start()
    assert dm.runner is None
开发者ID:ZanderBrown,项目名称:mu,代码行数:10,代码来源:test_debug.py


示例16: test_debug_on_stack_no_stack

def test_debug_on_stack_no_stack():
    """
    In certain rare situations the runner could send an empty stack.

    ToDo: Look into this.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debug_on_stack([])
    assert view.update_debug_inspector.call_count == 0
开发者ID:ZanderBrown,项目名称:mu,代码行数:11,代码来源:test_debug.py


示例17: test_debug_button_step_in

def test_debug_button_step_in():
    """
    Ensure the do_step method is called when the step-in button is clicked.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.button_step_in(None)
    dm.debugger.do_step.assert_called_once_with()
    assert view.current_tab.reset_debugger_highlight.call_count == 1
开发者ID:ZanderBrown,项目名称:mu,代码行数:11,代码来源:test_debug.py


示例18: test_debug_on_exception

def test_debug_on_exception():
    """
    Since an exception has been signalled, allow the script to run to the
    end of life so the error is correctly reported via stdout.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    dm.debugger = mock.MagicMock()
    dm.debug_on_exception("Exception", "Exception information")
    dm.debugger.do_run.assert_called_once_with()
    assert view.current_tab.reset_debugger_highlight.call_count == 1
开发者ID:ZanderBrown,项目名称:mu,代码行数:12,代码来源:test_debug.py


示例19: test_debug_on_line

def test_debug_on_line():
    """
    Ensure the view is updated to the expected tab and the correct line is
    selected therein.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    dm = DebugMode(editor, view)
    mock_tab = mock.MagicMock()
    editor.get_tab.return_value = mock_tab
    dm.debug_on_line('foo.py', 100)
    view.current_tab.setSelection.assert_called_once_with(0, 0, 0, 0)
    mock_tab.setSelection(99, 0, 100, 0)
开发者ID:ZanderBrown,项目名称:mu,代码行数:13,代码来源:test_debug.py


示例20: test_debug_start_prompt_for_unsaved_file

def test_debug_start_prompt_for_unsaved_file():
    """
    If the file hasn't been saved yet (it's unnamed), prompt the user to save
    it.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.current_tab.path = None
    dm = DebugMode(editor, view)
    dm.stop = mock.MagicMock()
    dm.start()
    editor.save.assert_called_once_with()
    assert dm.runner is None
    dm.stop.assert_called_once_with()
开发者ID:ZanderBrown,项目名称:mu,代码行数:14,代码来源:test_debug.py



注:本文中的mu.modes.debugger.DebugMode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python microbit.MicrobitMode类代码示例发布时间:2022-05-27
下一篇:
Python cmdlinetool.LogFileTool类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap