本文整理匯總了Python中mu.modes.python3.PythonMode.runner方法的典型用法代碼示例。如果您正苦於以下問題:Python PythonMode.runner方法的具體用法?Python PythonMode.runner怎麽用?Python PythonMode.runner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mu.modes.python3.PythonMode
的用法示例。
在下文中一共展示了PythonMode.runner方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_python_on_data_flood
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [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()
示例2: test_python_on_kernel_start
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [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
示例3: test_python_run_toggle_on
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [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)
示例4: test_python_add_plotter
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [as 別名]
def test_python_add_plotter():
"""
Ensure the plotter is added as expected.
"""
editor = mock.MagicMock()
view = mock.MagicMock()
pm = PythonMode(editor, view)
pm.set_buttons = mock.MagicMock()
pm.add_plotter()
view.add_python3_plotter.assert_called_once_with(pm)
assert pm.plotter
pm.set_buttons.assert_called_once_with(debug=False)
# Check button states are updated depending on other aspects of the mode
# being enabled.
# REPL active.
pm.set_buttons.reset_mock()
pm.repl = True
pm.add_plotter()
assert pm.set_buttons.call_count == 2
assert pm.set_buttons.call_args_list[0][1]['debug'] is False
assert pm.set_buttons.call_args_list[1][1]['run'] is False
# Runner active.
pm.set_buttons.reset_mock()
pm.repl = False
pm.runner = True
pm.add_plotter()
assert pm.set_buttons.call_count == 2
assert pm.set_buttons.call_args_list[0][1]['debug'] is False
assert pm.set_buttons.call_args_list[1][1]['repl'] is False
示例5: test_python_stop_script_no_runner
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [as 別名]
def test_python_stop_script_no_runner():
"""
If the script is cancelled before the child process is created ensure
nothing breaks and the UI is reset.
"""
editor = mock.MagicMock()
view = mock.MagicMock()
pm = PythonMode(editor, view)
pm.runner = None
pm.stop_script()
view.remove_python_runner.assert_called_once_with()
示例6: test_python_stop_resets_focus
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [as 別名]
def test_python_stop_resets_focus():
"""
Check that, when a child process is killed, the current
tab regains focus.
"""
editor = mock.MagicMock()
view = mock.MagicMock()
pm = PythonMode(editor, view)
mock_runner = mock.MagicMock()
pm.runner = mock_runner
pm.stop_script()
view.current_tab.setFocus.assert_called_once_with()
示例7: test_python_stop_script
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [as 別名]
def test_python_stop_script():
"""
Check that the child process is killed, the runner cleaned up and UI
is reset.
"""
editor = mock.MagicMock()
view = mock.MagicMock()
pm = PythonMode(editor, view)
mock_runner = mock.MagicMock()
pm.runner = mock_runner
pm.stop_script()
mock_runner.process.kill.assert_called_once_with()
mock_runner.process.waitForFinished.assert_called_once_with()
assert pm.runner is None
示例8: test_python_run_toggle_on_cancelled
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [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
示例9: test_python_run_toggle_off
# 需要導入模塊: from mu.modes.python3 import PythonMode [as 別名]
# 或者: from mu.modes.python3.PythonMode import runner [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)