Пример #1
0
def test_ModeSelector_setup():
    """
    Ensure the ModeSelector dialog is setup properly given a list of modes.

    If a mode has debugger = True it is ignored since debug mode is not a mode
    to be selected by users.
    """
    editor = mock.MagicMock()
    view = mock.MagicMock()
    modes = {
        'python': PythonMode(editor, view),
        'adafruit': AdafruitMode(editor, view),
        'microbit': MicrobitMode(editor, view),
        'debugger': DebugMode(editor, view),
    }
    current_mode = 'python'
    mock_item = mock.MagicMock()
    with mock.patch('mu.interface.dialogs.ModeItem', mock_item):
        ms = mu.interface.dialogs.ModeSelector()
        ms.setup(modes, current_mode, 'day')
    assert mock_item.call_count == 3
Пример #2
0
def setup_modes(editor, view):
    """
    Create a simple dictionary to hold instances of the available modes.

    *PREMATURE OPTIMIZATION ALERT* This may become more complex in future so
    splitting things out here to contain the mess. ;-)
    """
    modes = {
        'python': PythonMode(editor, view),
        'adafruit': AdafruitMode(editor, view),
        'calliope': CalliopeMode(editor, view),
        'microbit': MicrobitMode(editor, view),
        'debugger': DebugMode(editor, view),
    }

    # Check if pgzero is available (without importing it)
    if any([m for m in pkgutil.iter_modules() if 'pgzero' in m]):
        modes['pygamezero'] = PyGameZeroMode(editor, view)

    # return available modes
    return modes
Пример #3
0
def setup_modes(editor, view):
    """
    Create a simple dictionary to hold instances of the available modes.

    *PREMATURE OPTIMIZATION ALERT* This may become more complex in future so
    splitting things out here to contain the mess. ;-)
    """
    modes = {
        "python": PythonMode(editor, view),
        "circuitpython": CircuitPythonMode(editor, view),
        "microbit": MicrobitMode(editor, view),
        "esp": ESPMode(editor, view),
        "web": WebMode(editor, view),
        "debugger": DebugMode(editor, view),
    }

    # Check if pgzero is available (without importing it)
    if any([m for m in pkgutil.iter_modules() if "pgzero" in m]):
        modes["pygamezero"] = PyGameZeroMode(editor, view)

    # return available modes
    return modes