diff options
Diffstat (limited to 'git/test')
| -rw-r--r-- | git/test/fixtures/blame_incremental | 30 | ||||
| -rw-r--r-- | git/test/test_index.py | 11 | ||||
| -rw-r--r-- | git/test/test_repo.py | 30 |
3 files changed, 68 insertions, 3 deletions
diff --git a/git/test/fixtures/blame_incremental b/git/test/fixtures/blame_incremental new file mode 100644 index 00000000..9a0d9e35 --- /dev/null +++ b/git/test/fixtures/blame_incremental @@ -0,0 +1,30 @@ +82b8902e033430000481eb355733cd7065342037 2 2 1 +author Sebastian Thiel +author-mail <byronimo@gmail.com> +author-time 1270634931 +author-tz +0200 +committer Sebastian Thiel +committer-mail <byronimo@gmail.com> +committer-time 1270634931 +committer-tz +0200 +summary Used this release for a first beta of the 0.2 branch of development +previous 501bf602abea7d21c3dbb409b435976e92033145 AUTHORS +filename AUTHORS +82b8902e033430000481eb355733cd7065342037 14 14 1 +filename AUTHORS +c76852d0bff115720af3f27acdb084c59361e5f6 1 1 1 +author Michael Trier +author-mail <mtrier@gmail.com> +author-time 1232829627 +author-tz -0500 +committer Michael Trier +committer-mail <mtrier@gmail.com> +committer-time 1232829627 +committer-tz -0500 +summary Lots of spring cleaning and added in Sphinx documentation. +previous bcd57e349c08bd7f076f8d6d2f39b702015358c1 AUTHORS +filename AUTHORS +c76852d0bff115720af3f27acdb084c59361e5f6 2 3 11 +filename AUTHORS +c76852d0bff115720af3f27acdb084c59361e5f6 13 15 2 +filename AUTHORS diff --git a/git/test/test_index.py b/git/test/test_index.py index a928fe5e..f5f9d707 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -796,3 +796,14 @@ class TestIndex(TestBase): r = Repo.init(rw_dir) r.index.add([fp]) r.index.commit('Added orig and prestable') + + @with_rw_directory + def test_add_a_file_with_wildcard_chars(self, rw_dir): + # see issue #407 + fp = os.path.join(rw_dir, '[.exe') + with open(fp, "wb") as f: + f.write(b'something') + + r = Repo.init(rw_dir) + r.index.add([fp]) + r.index.commit('Added [.exe') diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 5035cbb9..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") @@ -454,7 +478,7 @@ class TestRepo(TestBase): assert s.readline() == l1 assert s.readline() == l2 assert s.readline() == l3 - assert s.readline() == '' + assert s.readline() == b'' assert s._stream.tell() == len(d) # readline limit @@ -465,13 +489,13 @@ class TestRepo(TestBase): # readline on tiny section s = mktiny() assert s.readline() == l1p - assert s.readline() == '' + assert s.readline() == b'' assert s._stream.tell() == ts + 1 # read no limit s = mkfull() assert s.read() == d[:-1] - assert s.read() == '' + assert s.read() == b'' assert s._stream.tell() == len(d) # read limit |
