本文整理汇总了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
示例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/")