diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2016-04-14 07:41:58 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2016-04-14 07:41:58 +0200 |
commit | 20a338ff049e7febe97411a6dc418a02ec11eefa (patch) | |
tree | 23227b6e4f39981a1099519b3187d37f06bd02c3 /git/test/test_repo.py | |
parent | 978eb5bd4751acf9d53c8b6626dc3f7832a20ccf (diff) | |
parent | f533a68cb5295f912da05e061a0b9bca05b3f0c8 (diff) | |
download | gitpython-20a338ff049e7febe97411a6dc418a02ec11eefa.tar.gz |
Merge pull request #409 from nvie/add-incremental-blame-support
Add incremental blame support
Diffstat (limited to 'git/test/test_repo.py')
-rw-r--r-- | git/test/test_repo.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 177aa176..ab6c502f 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -50,6 +50,16 @@ from io import BytesIO from nose import SkipTest +def iter_flatten(lol): + for items in lol: + for item in items: + yield item + + +def flatten(lol): + return list(iter_flatten(lol)) + + class TestRepo(TestBase): @raises(InvalidGitRepositoryError) @@ -324,6 +334,20 @@ class TestRepo(TestBase): assert nml, "There should at least be one blame commit that contains multiple lines" @patch.object(Git, '_call_process') + def test_blame_incremental(self, git): + git.return_value = fixture('blame_incremental') + blame_output = self.rorepo.blame_incremental('9debf6b0aafb6f7781ea9d1383c86939a1aacde3', 'AUTHORS') + blame_output = list(blame_output) + assert len(blame_output) == 5 + + # Check all outputted line numbers + ranges = flatten([line_numbers for _, line_numbers in blame_output]) + assert ranges == flatten([range(2, 3), range(14, 15), range(1, 2), range(3, 14), range(15, 17)]), str(ranges) + + commits = [c.hexsha[:7] for c, _ in blame_output] + assert commits == ['82b8902', '82b8902', 'c76852d', 'c76852d', 'c76852d'], str(commits) + + @patch.object(Git, '_call_process') def test_blame_complex_revision(self, git): git.return_value = fixture('blame_complex_revision') res = self.rorepo.blame("HEAD~10..HEAD", "README.md") |