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


Python CurrentView.rename方法代码示例

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


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

示例1: test_rename

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import rename [as 别名]
    def test_rename(self):
        mocked_re = MagicMock()
        mocked_index = MagicMock()
        mocked_os = MagicMock()
        mocked_result = MagicMock()

        mocked_result.rename.return_value = True
        mocked_re.sub.return_value = "new"
        mocked_os.path.split.return_value = [1, 1]

        with patch.multiple('gitfs.views.current', re=mocked_re,
                            os=mocked_os):
            from gitfs.views import current as current_view
            old_rename = current_view.PassthroughView.rename
            current_view.PassthroughView.rename = lambda self, old, new: True

            current = CurrentView(regex="regex", repo="repo",
                                  repo_path="repo_path",
                                  ignore=CachedIgnore())
            current._stage = mocked_index

            result = current.rename("old", "new")
            assert result is True
            mocked_index.assert_called_once_with(**{
                'remove': 1,
                'add': "new",
                "message": "Rename old to new"
            })
            mocked_os.path.split.assert_called_once_with("old")
            current_view.PassthroughView.rename = old_rename
开发者ID:Marius786,项目名称:gitfs,代码行数:32,代码来源:test_current.py

示例2: test_rename_in_git_dir

# 需要导入模块: from gitfs.views.current import CurrentView [as 别名]
# 或者: from gitfs.views.current.CurrentView import rename [as 别名]
 def test_rename_in_git_dir(self):
     current = CurrentView(repo="repo", repo_path="repo_path",
                           ignore=CachedIgnore())
     with pytest.raises(FuseOSError):
         current.rename(".git/", ".git/")
开发者ID:Marius786,项目名称:gitfs,代码行数:7,代码来源:test_current.py


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