diff options
| author | Vincent Driessen <me@nvie.com> | 2016-04-19 21:46:59 +0200 | 
|---|---|---|
| committer | Vincent Driessen <me@nvie.com> | 2016-04-19 21:46:59 +0200 | 
| commit | 8bbf1a3b801fb4e00c10f631faa87114dcd0462f (patch) | |
| tree | a231962fc64fb5b255d87ecb409bfc1f48dfe8a5 /git/test/test_diff.py | |
| parent | 0d7a40f603412be7e1046b500057b08558d9d250 (diff) | |
| parent | 1445b59bb41c4b1a94b7cb0ec6864c98de63814b (diff) | |
| download | gitpython-8bbf1a3b801fb4e00c10f631faa87114dcd0462f.tar.gz | |
Merge pull request #412 from nvie/fix-diff-patch-parsing
Fix diff patch parsing
Diffstat (limited to 'git/test/test_diff.py')
| -rw-r--r-- | git/test/test_diff.py | 13 | 
1 files changed, 10 insertions, 3 deletions
diff --git a/git/test/test_diff.py b/git/test/test_diff.py index 56e395fd..0c670f0b 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -76,7 +76,7 @@ class TestDiff(TestBase):          self._assert_diff_format(diffs)          assert_equal(1, len(diffs)) -        assert_equal(10, len(diffs[0].diff.splitlines())) +        assert_equal(8, len(diffs[0].diff.splitlines()))      def test_diff_with_rename(self):          output = StringProcessAdapter(fixture('diff_rename')) @@ -116,7 +116,7 @@ class TestDiff(TestBase):          res = Diff._index_from_patch_format(None, output.stdout)          assert len(res) == 6          for dr in res: -            assert dr.diff +            assert dr.diff.startswith(b'@@')              assert str(dr), "Diff to string conversion should be possible"          # end for each diff @@ -140,7 +140,8 @@ class TestDiff(TestBase):          # ...and with creating a patch          diff_index = initial_commit.diff(NULL_TREE, create_patch=True) -        assert diff_index[0].b_path == 'CHANGES' +        assert diff_index[0].a_path is None, repr(diff_index[0].a_path) +        assert diff_index[0].b_path == 'CHANGES', repr(diff_index[0].b_path)          assert diff_index[0].new_file          assert diff_index[0].diff == fixture('diff_initial') @@ -156,6 +157,12 @@ class TestDiff(TestBase):              Diff._index_from_patch_format(self.rorepo, diff_proc.stdout)          # END for each fixture +    def test_diff_with_spaces(self): +        data = StringProcessAdapter(fixture('diff_file_with_spaces')) +        diff_index = Diff._index_from_patch_format(self.rorepo, data.stdout) +        assert diff_index[0].a_path is None, repr(diff_index[0].a_path) +        assert diff_index[0].b_path == u'file with spaces', repr(diff_index[0].b_path) +      def test_diff_interface(self):          # test a few variations of the main diff routine          assertion_map = dict()  | 
