当前位置: 首页>>代码示例>>Python>>正文


Python MicrobitMode.user_defined_microbit_path方法代码示例

本文整理汇总了Python中mu.modes.microbit.MicrobitMode.user_defined_microbit_path方法的典型用法代码示例。如果您正苦于以下问题:Python MicrobitMode.user_defined_microbit_path方法的具体用法?Python MicrobitMode.user_defined_microbit_path怎么用?Python MicrobitMode.user_defined_microbit_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mu.modes.microbit.MicrobitMode的用法示例。


在下文中一共展示了MicrobitMode.user_defined_microbit_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_flash_path_specified_does_not_exist

# 需要导入模块: from mu.modes.microbit import MicrobitMode [as 别名]
# 或者: from mu.modes.microbit.MicrobitMode import user_defined_microbit_path [as 别名]
def test_flash_path_specified_does_not_exist():
    """
    Ensure that if a micro:bit is not automatically found by uflash and the
    user has previously specified a path to the device, then the hex is saved
    in the specified location.
    """
    with mock.patch('mu.logic.uflash.hexlify', return_value=''), \
            mock.patch('mu.logic.uflash.embed_hex', return_value='foo'), \
            mock.patch('mu.logic.uflash.find_microbit', return_value=None),\
            mock.patch('mu.logic.os.path.exists', return_value=False),\
            mock.patch('mu.logic.os.makedirs', return_value=None), \
            mock.patch('mu.logic.uflash.save_hex', return_value=None) as s:
        view = mock.MagicMock()
        view.current_tab.text = mock.MagicMock(return_value='')
        view.show_message = mock.MagicMock()
        editor = mock.MagicMock()
        mm = MicrobitMode(editor, view)
        mm.user_defined_microbit_path = 'baz'
        mm.flash()
        message = 'Could not find an attached BBC micro:bit.'
        information = ("Please ensure you leave enough time for the BBC"
                       " micro:bit to be attached and configured correctly"
                       " by your computer. This may take several seconds."
                       " Alternatively, try removing and re-attaching the"
                       " device or saving your work and restarting Mu if"
                       " the device remains unfound.")
        view.show_message.assert_called_once_with(message, information)
        assert s.call_count == 0
        assert mm.user_defined_microbit_path is None
开发者ID:lordmauve,项目名称:mu,代码行数:31,代码来源:test_microbit.py

示例2: test_flash_existing_user_specified_device_path

# 需要导入模块: from mu.modes.microbit import MicrobitMode [as 别名]
# 或者: from mu.modes.microbit.MicrobitMode import user_defined_microbit_path [as 别名]
def test_flash_existing_user_specified_device_path():
    """
    Ensure that if a micro:bit is not automatically found by uflash and the
    user has previously specified a path to the device, then the hex is saved
    in the specified location.
    """
    mock_flasher = mock.MagicMock()
    mock_flasher_class = mock.MagicMock(return_value=mock_flasher)
    with mock.patch('mu.logic.uflash.find_microbit', return_value=None),\
            mock.patch('mu.logic.os.path.exists', return_value=True),\
            mock.patch('mu.modes.microbit.DeviceFlasher',
                       mock_flasher_class), \
            mock.patch('mu.modes.microbit.sys.platform', 'win32'):
        view = mock.MagicMock()
        view.current_tab.text = mock.MagicMock(return_value='foo')
        view.get_microbit_path = mock.MagicMock(return_value='bar')
        view.show_message = mock.MagicMock()
        editor = mock.MagicMock()
        mm = MicrobitMode(editor, view)
        mm.user_defined_microbit_path = 'baz'
        mm.flash()
        assert view.get_microbit_path.call_count == 0
        assert editor.show_status_message.call_count == 1
        mock_flasher_class.assert_called_once_with(['baz', ], b'foo', None)
开发者ID:lordmauve,项目名称:mu,代码行数:26,代码来源:test_microbit.py


注:本文中的mu.modes.microbit.MicrobitMode.user_defined_microbit_path方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。