本文整理匯總了Python中mu.modes.python3.PythonMode.add_repl方法的典型用法代碼示例。如果您正苦於以下問題:Python PythonMode.add_repl方法的具體用法?Python PythonMode.add_repl怎麽用?Python PythonMode.add_repl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mu.modes.python3.PythonMode
的用法示例。
在下文中一共展示了PythonMode.add_repl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_python_add_repl
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import add_repl [as 別名]
def test_python_add_repl():
"""
Check the REPL's kernal manager is configured correctly before being handed
to the Jupyter widget in the view.
"""
mock_qthread = mock.MagicMock()
mock_kernel_runner = mock.MagicMock()
editor = mock.MagicMock()
editor.envars = [['name', 'value'], ]
view = mock.MagicMock()
pm = PythonMode(editor, view)
pm.set_buttons = mock.MagicMock()
pm.stop_kernel = mock.MagicMock()
with mock.patch('mu.modes.python3.QThread', mock_qthread), \
mock.patch('mu.modes.python3.KernelRunner', mock_kernel_runner):
pm.add_repl()
mock_qthread.assert_called_once_with()
mock_kernel_runner.assert_called_once_with(cwd=pm.workspace_dir(),
envars=editor.envars)
assert pm.kernel_thread == mock_qthread()
assert pm.kernel_runner == mock_kernel_runner()
pm.set_buttons.assert_called_once_with(repl=False)
pm.kernel_runner.moveToThread.assert_called_once_with(pm.kernel_thread)
pm.kernel_runner.kernel_started.connect.\
assert_called_once_with(pm.on_kernel_start)
pm.kernel_runner.kernel_finished.connect.\
assert_called_once_with(pm.kernel_thread.quit)
pm.stop_kernel.connect.\
assert_called_once_with(pm.kernel_runner.stop_kernel)
pm.kernel_thread.started.connect.\
assert_called_once_with(pm.kernel_runner.start_kernel)
pm.kernel_thread.finished.connect.\
assert_called_once_with(pm.on_kernel_stop)
pm.kernel_thread.start.assert_called_once_with()
示例2: test_python_toggle_repl
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import add_repl [as 別名]
def test_python_toggle_repl():
"""
Ensure the REPL handling works as expected.
"""
editor = mock.MagicMock()
view = mock.MagicMock()
pm = PythonMode(editor, view)
pm.add_repl = mock.MagicMock()
pm.remove_repl = mock.MagicMock()
pm.toggle_repl(None)
pm.add_repl.assert_called_once_with()
pm.kernel_runner = True
pm.toggle_repl(None)
pm.remove_repl.assert_called_once_with()