Skip to content

Commit 8fed583

Browse files
committed
try fixing up test fixtures and implementation
1 parent 90a6e1c commit 8fed583

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

git/diff.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -511,11 +511,11 @@ def handle_diff_line(line):
511511
new_file = True
512512
elif change_type == 'C':
513513
copied_file = True
514-
a_path, b_path = path.split('\t', 1)
514+
a_path, b_path = path.split('\x00', 1)
515515
a_path = a_path.encode(defenc)
516516
b_path = b_path.encode(defenc)
517517
elif change_type == 'R':
518-
a_path, b_path = path.split('\t', 1)
518+
a_path, b_path = path.split('\x00', 1)
519519
a_path = a_path.encode(defenc)
520520
b_path = b_path.encode(defenc)
521521
rename_from, rename_to = a_path, b_path

test/test_diff.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525

2626
import os.path as osp
2727

28+
def to_raw(input):
29+
return input.replace(b'\t', b'\x00')
30+
2831

2932
@ddt.ddt
3033
class TestDiff(TestBase):
@@ -112,7 +115,7 @@ def test_diff_with_rename(self):
112115
self.assertEqual(diff.raw_rename_to, b'm\xc3\xbcller')
113116
assert isinstance(str(diff), str)
114117

115-
output = StringProcessAdapter(fixture('diff_rename_raw'))
118+
output = StringProcessAdapter(to_raw(fixture('diff_rename_raw')))
116119
diffs = Diff._index_from_raw_format(self.rorepo, output)
117120
self.assertEqual(len(diffs), 1)
118121
diff = diffs[0]
@@ -137,7 +140,7 @@ def test_diff_with_copied_file(self):
137140
self.assertTrue(diff.b_path, 'test2.txt')
138141
assert isinstance(str(diff), str)
139142

140-
output = StringProcessAdapter(fixture('diff_copied_mode_raw'))
143+
output = StringProcessAdapter(to_raw(fixture('diff_copied_mode_raw')))
141144
diffs = Diff._index_from_raw_format(self.rorepo, output)
142145
self.assertEqual(len(diffs), 1)
143146
diff = diffs[0]
@@ -165,7 +168,7 @@ def test_diff_with_change_in_type(self):
165168
self.assertIsNotNone(diff.new_file)
166169
assert isinstance(str(diff), str)
167170

168-
output = StringProcessAdapter(fixture('diff_change_in_type_raw'))
171+
output = StringProcessAdapter(to_raw(fixture('diff_change_in_type_raw')))
169172
diffs = Diff._index_from_raw_format(self.rorepo, output)
170173
self.assertEqual(len(diffs), 1)
171174
diff = diffs[0]
@@ -175,7 +178,7 @@ def test_diff_with_change_in_type(self):
175178
self.assertEqual(len(list(diffs.iter_change_type('T'))), 1)
176179

177180
def test_diff_of_modified_files_not_added_to_the_index(self):
178-
output = StringProcessAdapter(fixture('diff_abbrev-40_full-index_M_raw_no-color'))
181+
output = StringProcessAdapter(to_raw(fixture('diff_abbrev-40_full-index_M_raw_no-color')))
179182
diffs = Diff._index_from_raw_format(self.rorepo, output)
180183

181184
self.assertEqual(len(diffs), 1, 'one modification')

0 commit comments

Comments
 (0)