当前位置: 首页>>代码示例>>Python>>正文


Python PythonMode.run_toggle方法代码示例

本文整理汇总了Python中mu.modes.python3.PythonMode.run_toggle方法的典型用法代码示例。如果您正苦于以下问题:Python PythonMode.run_toggle方法的具体用法?Python PythonMode.run_toggle怎么用?Python PythonMode.run_toggle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mu.modes.python3.PythonMode的用法示例。


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

示例1: test_python_run_toggle_on

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import run_toggle [as 别名]
def test_python_run_toggle_on():
    """
    Check the handler for clicking run starts the new process and updates the
    UI state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.button_bar.slots = {
        'debug': mock.MagicMock(),
        'modes': mock.MagicMock(),
        'run': mock.MagicMock(),
    }
    pm = PythonMode(editor, view)
    pm.runner = None

    def runner(pm=pm):
        pm.runner = True

    pm.run_script = mock.MagicMock(side_effect=runner)
    pm.run_toggle(None)
    pm.run_script.assert_called_once_with()
    slot = pm.view.button_bar.slots['run']
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with('Stop')
    slot.setToolTip.assert_called_once_with('Stop your Python script.')
    pm.view.button_bar.slots['debug'].setEnabled.assert_called_once_with(False)
    pm.view.button_bar.slots['modes'].setEnabled.assert_called_once_with(False)
开发者ID:martinohanlon,项目名称:mu,代码行数:29,代码来源:test_python3.py

示例2: test_python_run_toggle_on_cancelled

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import run_toggle [as 别名]
def test_python_run_toggle_on_cancelled():
    """
    Ensure the button states are correct if running an unsaved script is
    cancelled before the process is allowed to start. See issue #338.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    pm.runner = None
    pm.run_script = mock.MagicMock()
    pm.run_toggle(None)
    pm.run_script.assert_called_once_with()
    slot = pm.view.button_bar.slots['run']
    assert slot.setIcon.call_count == 0
开发者ID:martinohanlon,项目名称:mu,代码行数:16,代码来源:test_python3.py

示例3: test_python_on_data_flood

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import run_toggle [as 别名]
def test_python_on_data_flood():
    """
    Ensure that Python 3 mode cleans up correctly after a data flood of the
    plotter is detected: reset the buttons, stop either the REPL or runner and
    then call the base method.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    pm.set_buttons = mock.MagicMock()
    pm.run_toggle = mock.MagicMock()
    pm.remove_repl = mock.MagicMock()
    pm.runner = True
    with mock.patch('builtins.super') as mock_super:
        pm.on_data_flood()
        pm.set_buttons.assert_called_once_with(run=True, repl=True, debug=True)
        pm.run_toggle.assert_called_once_with(None)
        mock_super().on_data_flood.assert_called_once_with()
    pm.set_buttons.reset_mock()
    pm.runner = False
    pm.kernel_runner = True
    with mock.patch('builtins.super') as mock_super:
        pm.on_data_flood()
        pm.set_buttons.assert_called_once_with(run=True, repl=True, debug=True)
        pm.remove_repl.assert_called_once_with()
        mock_super().on_data_flood.assert_called_once_with()
开发者ID:martinohanlon,项目名称:mu,代码行数:28,代码来源:test_python3.py

示例4: test_python_run_toggle_off

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import run_toggle [as 别名]
def test_python_run_toggle_off():
    """
    Check the handler for clicking run stops the process and reverts the UI
    state.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    pm.runner = True
    pm.stop_script = mock.MagicMock()
    pm.run_toggle(None)
    pm.stop_script.assert_called_once_with()
    slot = pm.view.button_bar.slots['run']
    assert slot.setIcon.call_count == 1
    slot.setText.assert_called_once_with('Run')
    slot.setToolTip.assert_called_once_with('Run your Python script.')
    pm.view.button_bar.slots['debug'].setEnabled.assert_called_once_with(True)
开发者ID:lordmauve,项目名称:mu,代码行数:19,代码来源:test_python3.py


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