From 1019d4cf68d1acdbb4d6c1abb7e71ac9c0f581af Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Tue, 25 May 2010 20:11:43 +0200 Subject: diff: by limiting the splitcount to 5, a subtle bug was introduced as the newline at the end of the split line was not split away automatically. Added test for this, and the trivial fix Wow, at least two people reviewd the code, but it slipped through anyway :) --- test/git/test_diff.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/git/test_diff.py') diff --git a/test/git/test_diff.py b/test/git/test_diff.py index 5df39df1..2f6a19bd 100644 --- a/test/git/test_diff.py +++ b/test/git/test_diff.py @@ -8,17 +8,30 @@ from test.testlib import * from git import * class TestDiff(TestBase): + + def _assert_diff_format(self, diffs): + # verify that the format of the diff is sane + for diff in diffs: + if diff.a_blob: + assert not diff.a_blob.path.endswith('\n') + if diff.b_blob: + assert not diff.b_blob.path.endswith('\n') + # END for each diff + return diffs def test_list_from_string_new_mode(self): output = ListProcessAdapter(fixture('diff_new_mode')) diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) + self._assert_diff_format(diffs) + assert_equal(1, len(diffs)) assert_equal(10, len(diffs[0].diff.splitlines())) def test_diff_with_rename(self): output = ListProcessAdapter(fixture('diff_rename')) diffs = Diff._index_from_patch_format(self.rorepo, output.stdout) - + self._assert_diff_format(diffs) + assert_equal(1, len(diffs)) diff = diffs[0] @@ -54,6 +67,7 @@ class TestDiff(TestBase): assert isinstance(diff_index, DiffIndex) if diff_index: + self._assert_diff_format(diff_index) for ct in DiffIndex.change_type: key = 'ct_%s'%ct assertion_map.setdefault(key, 0) -- cgit v1.2.1