Example #1
0
def test_micropython_mode_add_repl_no_force_interrupt():
    """
    Nothing goes wrong so check the _view.add_micropython_repl gets the
    expected arguments (including the flag so no keyboard interrupt is called).
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.show_message = mock.MagicMock()
    view.add_micropython_repl = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.force_interrupt = False
    mm.find_device = mock.MagicMock(return_value=('COM0', '12345'))
    with mock.patch('os.name', 'nt'):
        mm.add_repl()
    assert view.show_message.call_count == 0
    assert view.add_micropython_repl.call_args[0][0] == 'COM0'
    assert view.add_micropython_repl.call_args[0][2] is False
Example #2
0
def test_micropython_mode_add_repl_no_force_interrupt():
    """
    Nothing goes wrong so check the _view.add_micropython_repl gets the
    expected arguments (including the flag so no keyboard interrupt is called).
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    view.show_message = mock.MagicMock()
    view.add_micropython_repl = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.force_interrupt = False
    mm.find_device = mock.MagicMock(return_value=('COM0', '12345'))
    with mock.patch('os.name', 'nt'):
        mm.add_repl()
    assert view.show_message.call_count == 0
    assert view.add_micropython_repl.call_args[0][0] == 'COM0'
    assert view.add_micropython_repl.call_args[0][2] is False
Example #3
0
def test_micropython_mode_add_repl_no_force_interrupt(microbit):
    """
    Nothing goes wrong so check the _view.add_micropython_repl gets the
    expected arguments (including the flag so no keyboard interrupt
    is called).
    """
    editor = mock.MagicMock()
    editor.current_device = microbit
    view = mock.MagicMock()
    view.show_message = mock.MagicMock()
    mm = MicroPythonMode(editor, view)
    mm.force_interrupt = False
    mock_repl_connection = mock.MagicMock()
    mock_connection_class = mock.MagicMock(return_value=mock_repl_connection)
    with mock.patch("mu.modes.base.REPLConnection", mock_connection_class):
        mm.add_repl()
    view.show_message.assert_not_called()
    mock_repl_connection.send_interrupt.assert_not_called()