Skip to content

Commit 21e2c45

Browse files
committed
try fixing up test fixtures and implementation
1 parent 90a6e1c commit 21e2c45

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

git/diff.py

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import os.path as osp
2727

2828

29+
def to_raw(input):
30+
return input.replace(b'\t', b'\x00')
31+
32+
2933
@ddt.ddt
3034
class TestDiff(TestBase):
3135

@@ -112,7 +116,7 @@ def test_diff_with_rename(self):
112116
self.assertEqual(diff.raw_rename_to, b'm\xc3\xbcller')
113117
assert isinstance(str(diff), str)
114118

115-
output = StringProcessAdapter(fixture('diff_rename_raw'))
119+
output = StringProcessAdapter(to_raw(fixture('diff_rename_raw')))
116120
diffs = Diff._index_from_raw_format(self.rorepo, output)
117121
self.assertEqual(len(diffs), 1)
118122
diff = diffs[0]
@@ -137,7 +141,7 @@ def test_diff_with_copied_file(self):
137141
self.assertTrue(diff.b_path, 'test2.txt')
138142
assert isinstance(str(diff), str)
139143

140-
output = StringProcessAdapter(fixture('diff_copied_mode_raw'))
144+
output = StringProcessAdapter(to_raw(fixture('diff_copied_mode_raw')))
141145
diffs = Diff._index_from_raw_format(self.rorepo, output)
142146
self.assertEqual(len(diffs), 1)
143147
diff = diffs[0]
@@ -165,7 +169,7 @@ def test_diff_with_change_in_type(self):
165169
self.assertIsNotNone(diff.new_file)
166170
assert isinstance(str(diff), str)
167171

168-
output = StringProcessAdapter(fixture('diff_change_in_type_raw'))
172+
output = StringProcessAdapter(to_raw(fixture('diff_change_in_type_raw')))
169173
diffs = Diff._index_from_raw_format(self.rorepo, output)
170174
self.assertEqual(len(diffs), 1)
171175
diff = diffs[0]
@@ -175,7 +179,7 @@ def test_diff_with_change_in_type(self):
175179
self.assertEqual(len(list(diffs.iter_change_type('T'))), 1)
176180

177181
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'))
182+
output = StringProcessAdapter(to_raw(fixture('diff_abbrev-40_full-index_M_raw_no-color')))
179183
diffs = Diff._index_from_raw_format(self.rorepo, output)
180184

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy