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


Python MagicMock.window方法代码示例

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


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

示例1: test_buffer_demotion

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def test_buffer_demotion(self, mock_indexer):
        """Buffer should be demoted from the hot list when it has been closed."""
        file_name = '/somedir/otherdir/test_file.c'
        win_id = 1

        mock_view = MagicMock()
        mock_view.window().id.return_value = win_id
        mock_view.file_name.return_value = file_name
        mock_view.is_scratch.return_value = False

        self.test_obj.on_close(mock_view)
        win_id += 1
        mock_view.window().id.return_value = win_id
        self.test_obj.on_close(mock_view)

        mock_indexer.buffer_demoted.assert_called_once_with(file_name)

        # Scratch buffers should be ignored
        mock_indexer.reset_mock()
        win_id += 1
        mock_view.is_scratch.return_value = True

        self.test_obj.on_post_save(mock_view)
        self.assertFalse(mock_indexer.window_state_changed.called)
        self.assertFalse(mock_indexer.buffer_promoted.called)
开发者ID:hushenshen,项目名称:SublimeCscope,代码行数:27,代码来源:test_event_listener.py

示例2: test_buffer_promotion

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def test_buffer_promotion(self, mock_indexer):
        """ Modified buffers should be promoted to hot list
        Buffer should be promoted to the hot list if it
        has been modified (just getting a save event is good enough).
        """

        file_name = '/somedir/otherdir/test_file.c'
        win_id = 1

        mock_view = MagicMock()
        mock_view.window().id.return_value = win_id
        mock_view.file_name.return_value = file_name
        mock_view.is_scratch.return_value = False

        self.test_obj.on_post_save(mock_view)
        win_id += 1
        mock_view.window().id.return_value = win_id
        self.test_obj.on_post_save(mock_view)

        # A change in window id should not trigger a window state change on buffer save
        self.assertFalse(mock_indexer.window_state_changed.called)

        mock_indexer.buffer_promoted.assert_called_once_with(file_name)

        # Scratch buffers should be ignored
        mock_indexer.reset_mock()
        win_id += 1
        mock_view.is_scratch.return_value = True

        self.test_obj.on_post_save(mock_view)

        self.assertFalse(mock_indexer.window_state_changed.called)
        self.assertFalse(mock_indexer.buffer_promoted.called)
开发者ID:hushenshen,项目名称:SublimeCscope,代码行数:35,代码来源:test_event_listener.py

示例3: test_handle_configure_request_floating

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def test_handle_configure_request_floating(self):
        wid = util.create_window(floating=True)
        event = MagicMock()
        event.window = wid

        with patch.object(pwm.windows, "configure") as conf:
            pwm.events.handle_configure_request(event)

        conf.assert_called_once()
开发者ID:linuscl,项目名称:pwm,代码行数:11,代码来源:test_events.py

示例4: test_handle_configure_request_tiling

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def test_handle_configure_request_tiling(self):
        wid = util.create_window()
        event = MagicMock()
        event.window = wid

        with patch.object(pwm.windows.managed[wid].workspace.tiling,
                          "arrange") as arr:
            pwm.events.handle_configure_request(event)

        arr.assert_called_once_with(wid)
开发者ID:linuscl,项目名称:pwm,代码行数:12,代码来源:test_events.py

示例5: test_handle_property_notify_name

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def test_handle_property_notify_name(self):
        wid = util.create_window()
        event = MagicMock()
        event.atom = pwm.atom.get("_NET_WM_NAME")
        event.window = wid

        with patch.object(pwm.events, "window_name_changed") as ev:
            pwm.events.handle_property_notify(event)

        ev.assert_called_once_with(wid)
开发者ID:linuscl,项目名称:pwm,代码行数:12,代码来源:test_events.py

示例6: _test_wm_state_urgent

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def _test_wm_state_urgent(self, wid, action):
        event = MagicMock()
        event.format = 32
        event.data.data32 = [action,
                             pwm.atom.get("_NET_WM_STATE_DEMANDS_ATTENTION")]
        event.window = wid

        with patch.object(pwm.windows, "toggle_urgent") as urgent:
            pwm.events.handle_wm_state(event)

        urgent.assert_called_once_with(wid)
开发者ID:linuscl,项目名称:pwm,代码行数:13,代码来源:test_events.py

示例7: _test_wm_state_fullscreen

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
    def _test_wm_state_fullscreen(self, wid, action):
        event = MagicMock()
        event.format = 32
        event.data.data32 = [action, pwm.atom.get("_NET_WM_STATE_FULLSCREEN")]
        event.window = wid

        with patch.object(pwm.windows.managed[wid].workspace,
                          "toggle_fullscreen") as toggle:
            pwm.events.handle_wm_state(event)

        toggle.assert_called_once_with(wid)
开发者ID:linuscl,项目名称:pwm,代码行数:13,代码来源:test_events.py

示例8: mock_view

# 需要导入模块: from unittest.mock import MagicMock [as 别名]
# 或者: from unittest.mock.MagicMock import window [as 别名]
def mock_view(file_path, window):
    view = MagicMock()
    view.file_name = Mock(return_value=os.path.join(window.folders()[0], file_path))
    view.match_selector = Mock(return_value=True)
    window.active_view = Mock(return_value=view)
    window.find_open_file = Mock(return_value=view)
    window.views = Mock(return_value=[view])
    view.window = Mock(return_value=window)
    region = MagicMock()
    region.begin = Mock(return_value=4)
    region.end = Mock(return_value=4)
    view.sel = Mock(return_value=[region])
    view.rowcol = Mock(return_value=(0, 0))
    view.text_point = Mock(return_value=4)
    return view
开发者ID:tomv564,项目名称:stack-ide-sublime,代码行数:17,代码来源:mocks.py


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