Skip to content

Commit b62b3ce

Browse files
committed
Better patch tests. They now all read from casefiles
1 parent 8100c63 commit b62b3ce

File tree

3 files changed

+143
-360
lines changed

3 files changed

+143
-360
lines changed

tests/test_apply.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def test_diff_default(self):
2626
with open('tests/casefiles/diff-default.diff') as f:
2727
diff_text = f.read()
2828

29-
diff = [x for x in wtp.parse_patch(diff_text)]
30-
diff = diff[0]
29+
diff = next(wtp.parse_patch(diff_text))
3130

3231
new_text = wtp.apply.apply_diff(diff, self.lao)
3332
self.assertEqual(new_text, self.tzu)
@@ -36,8 +35,7 @@ def test_diff_context(self):
3635
with open('tests/casefiles/diff-context.diff') as f:
3736
diff_text = f.read()
3837

39-
diff = [x for x in wtp.parse_patch(diff_text)]
40-
diff = diff[0]
38+
diff = next(wtp.parse_patch(diff_text))
4139

4240
new_text = wtp.apply.apply_diff(diff, self.lao)
4341
self.assertEqual(new_text, self.tzu)
@@ -46,8 +44,7 @@ def test_diff_unified(self):
4644
with open('tests/casefiles/diff-unified.diff') as f:
4745
diff_text = f.read()
4846

49-
diff = [x for x in wtp.parse_patch(diff_text)]
50-
diff = diff[0]
47+
diff = next(wtp.parse_patch(diff_text))
5148

5249
new_text = wtp.apply.apply_diff(diff, self.lao)
5350

@@ -57,8 +54,7 @@ def test_diff_unified_patchutil(self):
5754
with open('tests/casefiles/diff-unified.diff') as f:
5855
diff_text = f.read()
5956

60-
diff = [x for x in wtp.parse_patch(diff_text)]
61-
diff = diff[0]
57+
diff = next(wtp.parse_patch(diff_text))
6258

6359
new_text = wtp.apply.apply_diff(diff, self.lao, use_patch=True)
6460
self.assertEqual(new_text, (self.tzu, None))
@@ -69,8 +65,7 @@ def test_diff_rcs(self):
6965
with open('tests/casefiles/diff-rcs.diff') as f:
7066
diff_text = f.read()
7167

72-
diff = [x for x in wtp.parse_patch(diff_text)]
73-
diff = diff[0]
68+
diff = next(wtp.parse_patch(diff_text))
7469

7570
new_text = wtp.apply.apply_diff(diff, self.lao)
7671
self.assertEqual(new_text, self.tzu)
@@ -80,8 +75,7 @@ def test_diff_ed(self):
8075
with open('tests/casefiles/diff-ed.diff') as f:
8176
diff_text = f.read()
8277

83-
diff = [x for x in wtp.parse_patch(diff_text)]
84-
diff = diff[0]
78+
diff = next(wtp.parse_patch(diff_text))
8579

8680
new_text = wtp.apply.apply_diff(diff, self.lao)
8781
self.assertEqual(self.tzu,new_text)

0 commit comments

Comments
 (0)