本文整理汇总了Python中passpie.history.Repository.commit_by_index方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.commit_by_index方法的具体用法?Python Repository.commit_by_index怎么用?Python Repository.commit_by_index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类passpie.history.Repository
的用法示例。
在下文中一共展示了Repository.commit_by_index方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_commit_by_index_returns_none_when_index_not_found
# 需要导入模块: from passpie.history import Repository [as 别名]
# 或者: from passpie.history.Repository import commit_by_index [as 别名]
def test_commit_by_index_returns_none_when_index_not_found(mocker):
MockRepo = mocker.patch('passpie.history.Repo')
mock_repo = MockRepo()
commits = []
mock_repo.iter_commits.return_value = commits
index = len(commits) + 1
git = Repository('path')
commit = git.commit_by_index(index)
assert commit is None
示例2: test_commit_by_index_returns_found_commit_when_index_exists
# 需要导入模块: from passpie.history import Repository [as 别名]
# 或者: from passpie.history.Repository import commit_by_index [as 别名]
def test_commit_by_index_returns_found_commit_when_index_exists(mocker):
MockRepo = mocker.patch('passpie.history.Repo')
mock_repo = MockRepo()
commits = ['initial commit']
mock_repo.iter_commits.return_value = commits
index = 0
git = Repository('path')
commit = git.commit_by_index(index)
assert commit == commits[0]