本文整理汇总了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)