當前位置: 首頁>>代碼示例>>Python>>正文


Python PythonMode.plotter方法代碼示例

本文整理匯總了Python中mu.modes.python3.PythonMode.plotter方法的典型用法代碼示例。如果您正苦於以下問題:Python PythonMode.plotter方法的具體用法?Python PythonMode.plotter怎麽用?Python PythonMode.plotter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mu.modes.python3.PythonMode的用法示例。


在下文中一共展示了PythonMode.plotter方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_python_on_kernel_start

# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import plotter [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

示例2: test_python_run_script

# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import plotter [as 別名]
def test_python_run_script():
    """
    Ensure that running the script launches the process as expected.
    """
    editor = mock.MagicMock()
    editor.envars = [['name', 'value']]
    view = mock.MagicMock()
    view.current_tab.path = '/foo/bar'
    view.current_tab.isModified.return_value = True
    view.current_tab.text = mock.MagicMock(return_value="abc")
    mock_runner = mock.MagicMock()
    view.add_python3_runner.return_value = mock_runner
    pm = PythonMode(editor, view)
    pm.run_script()
    editor.save_tab_to_file.assert_called_once_with(view.current_tab)
    view.add_python3_runner.assert_called_once_with('/foo/bar', '/foo',
                                                    interactive=True,
                                                    envars=editor.envars)
    mock_runner.process.waitForStarted.assert_called_once_with()
    # Check the buttons are set to the correct state when other aspects of the
    # mode are also in play.
    pm.set_buttons = mock.MagicMock()
    pm.kernel_runner = True
    pm.run_script()
    pm.set_buttons.assert_called_once_with(plotter=False)
    pm.set_buttons.reset_mock()
    pm.kernel_runner = False
    pm.plotter = True
    pm.run_script()
    pm.set_buttons.assert_called_once_with(repl=False)
開發者ID:martinohanlon,項目名稱:mu,代碼行數:32,代碼來源:test_python3.py

示例3: test_python_toggle_plotter

# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import plotter [as 別名]
def test_python_toggle_plotter():
    """
    Ensure toggling the plotter causes it to be added/removed.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    pm = PythonMode(editor, view)
    pm.add_plotter = mock.MagicMock()
    pm.remove_plotter = mock.MagicMock()
    pm.toggle_plotter()
    pm.add_plotter.assert_called_once_with()
    pm.plotter = True
    pm.toggle_plotter()
    pm.remove_plotter.assert_called_once_with()
開發者ID:martinohanlon,項目名稱:mu,代碼行數:16,代碼來源:test_python3.py

示例4: test_python_run_script

# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import plotter [as 別名]
def test_python_run_script():
    """
    Ensure that running the script launches the process 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
    pm = PythonMode(editor, view)
    pm.workspace_dir = mock.MagicMock(return_value='/bar')
    with mock.patch('builtins.open') as oa, \
            mock.patch('mu.modes.python3.write_and_flush'):
        pm.run_script()
        oa.assert_called_once_with('/foo', 'w', newline='')
    view.add_python3_runner.assert_called_once_with('/foo', '/bar',
                                                    interactive=True,
                                                    envars=editor.envars)
    mock_runner.process.waitForStarted.assert_called_once_with()
    # Check the buttons are set to the correct state when other aspects of the
    # mode are also in play.
    pm.set_buttons = mock.MagicMock()
    pm.kernel_runner = True
    with mock.patch('builtins.open') as oa, \
            mock.patch('mu.modes.python3.write_and_flush'):
        pm.run_script()
    pm.set_buttons.assert_called_once_with(plotter=False)
    pm.set_buttons.reset_mock()
    pm.kernel_runner = False
    pm.plotter = True
    with mock.patch('builtins.open') as oa, \
            mock.patch('mu.modes.python3.write_and_flush'):
        pm.run_script()
    pm.set_buttons.assert_called_once_with(repl=False)
開發者ID:ZanderBrown,項目名稱:mu,代碼行數:38,代碼來源:test_python3.py


注:本文中的mu.modes.python3.PythonMode.plotter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。