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


Python PythonMode.on_kernel_start方法代码示例

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


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

示例1: test_python_on_kernel_start

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import on_kernel_start [as 别名]
def test_python_on_kernel_start():
    """
    Ensure the handler for when the kernel has started updates the UI such that
    the kernel manager and kernel client are used to add the Jupyter widget to
    the UI, the REPL button is re-enabled and a status update is shown.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    mock_kernel_manager = mock.MagicMock()
    mock_client = mock.MagicMock()
    pm.on_kernel_start(mock_kernel_manager, mock_client)
    view.add_jupyter_repl.assert_called_once_with(mock_kernel_manager,
                                                  mock_client)
    view.button_bar.slots['repl'].setEnabled.assert_called_once_with(True)
    editor.show_status_message.assert_called_once_with('REPL started.')
开发者ID:willingc,项目名称:mu,代码行数:18,代码来源:test_python3.py

示例2: test_python_on_kernel_start

# 需要导入模块: from mu.modes.python3 import PythonMode [as 别名]
# 或者: from mu.modes.python3.PythonMode import on_kernel_start [as 别名]
def test_python_on_kernel_start():
    """
    Ensure the handler for when the kernel has started updates the UI such that
    the kernel manager and kernel client are used to add the Jupyter widget to
    the UI, the REPL button is re-enabled and a status update is shown.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    pm.set_buttons = mock.MagicMock()
    mock_kernel_manager = mock.MagicMock()
    mock_client = mock.MagicMock()
    pm.on_kernel_start(mock_kernel_manager, mock_client)
    view.add_jupyter_repl.assert_called_once_with(mock_kernel_manager,
                                                  mock_client)
    pm.set_buttons.assert_called_once_with(repl=True)
    editor.show_status_message.assert_called_once_with('REPL started.')
    # Check button states are set according to what other aspects of the mode
    # are currently enabled.
    # With Runner enabled.
    pm.set_buttons.reset_mock()
    pm.runner = True
    pm.on_kernel_start(mock_kernel_manager, mock_client)
    assert pm.set_buttons.call_count == 2
    assert pm.set_buttons.call_args_list[0][1]['repl'] is True
    assert pm.set_buttons.call_args_list[1][1]['plotter'] is False
    # With Plotter enabled.
    pm.set_buttons.reset_mock()
    pm.runner = False
    pm.plotter = True
    pm.on_kernel_start(mock_kernel_manager, mock_client)
    assert pm.set_buttons.call_count == 2
    assert pm.set_buttons.call_args_list[0][1]['repl'] is True
    assert pm.set_buttons.call_args_list[1][1]['run'] is False
    assert pm.set_buttons.call_args_list[1][1]['debug'] is False
开发者ID:martinohanlon,项目名称:mu,代码行数:37,代码来源:test_python3.py


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