Commit 903887ab authored by Jelmer Vernooij's avatar Jelmer Vernooij

Avoid cluttering source directory with test files.

parent 542a4a26
...@@ -466,55 +466,67 @@ class TestPatienceDiffLibFiles(unittest.TestCase): ...@@ -466,55 +466,67 @@ class TestPatienceDiffLibFiles(unittest.TestCase):
unified_diff_files = patiencediff.unified_diff_files unified_diff_files = patiencediff.unified_diff_files
psm = self._PatienceSequenceMatcher psm = self._PatienceSequenceMatcher
self.assertEqual(['--- a1\n',
'+++ b1\n', old_pwd = os.getcwd()
'@@ -1,3 +1,2 @@\n', os.chdir(self.test_dir)
' hello there\n', try:
'-world\n', self.assertEqual(['--- a1\n',
' how are you today?\n', '+++ b1\n',
] '@@ -1,3 +1,2 @@\n',
, list(unified_diff_files('a1', 'b1', ' hello there\n',
sequencematcher=psm))) '-world\n',
' how are you today?\n',
]
, list(unified_diff_files('a1', 'b1',
sequencematcher=psm)))
finally:
os.chdir(old_pwd)
txt_a = [x+'\n' for x in 'abcdefghijklmnop'] txt_a = [x+'\n' for x in 'abcdefghijklmnop']
txt_b = [x+'\n' for x in 'abcdefxydefghijklmnop'] txt_b = [x+'\n' for x in 'abcdefxydefghijklmnop']
with open('a2', 'w') as f: f.writelines(txt_a) with open(os.path.join(self.test_dir, 'a2'), 'w') as f:
with open('b2', 'w') as f: f.writelines(txt_b) f.writelines(txt_a)
with open(os.path.join(self.test_dir, 'b2'), 'w') as f:
f.writelines(txt_b)
# This is the result with LongestCommonSubstring matching # This is the result with LongestCommonSubstring matching
self.assertEqual(['--- a2\n', os.chdir(self.test_dir)
'+++ b2\n', try:
'@@ -1,6 +1,11 @@\n', self.assertEqual(['--- a2\n',
' a\n', '+++ b2\n',
' b\n', '@@ -1,6 +1,11 @@\n',
' c\n', ' a\n',
'+d\n', ' b\n',
'+e\n', ' c\n',
'+f\n', '+d\n',
'+x\n', '+e\n',
'+y\n', '+f\n',
' d\n', '+x\n',
' e\n', '+y\n',
' f\n'] ' d\n',
, list(unified_diff_files('a2', 'b2'))) ' e\n',
' f\n']
# And the patience diff , list(unified_diff_files('a2', 'b2')))
self.assertEqual(['--- a2\n',
'+++ b2\n', # And the patience diff
'@@ -4,6 +4,11 @@\n', self.assertEqual(['--- a2\n',
' d\n', '+++ b2\n',
' e\n', '@@ -4,6 +4,11 @@\n',
' f\n', ' d\n',
'+x\n', ' e\n',
'+y\n', ' f\n',
'+d\n', '+x\n',
'+e\n', '+y\n',
'+f\n', '+d\n',
' g\n', '+e\n',
' h\n', '+f\n',
' i\n'], ' g\n',
list(unified_diff_files('a2', 'b2', ' h\n',
sequencematcher=psm))) ' i\n'],
list(unified_diff_files('a2', 'b2',
sequencematcher=psm)))
finally:
os.chdir(old_pwd)
class TestPatienceDiffLibFiles_c(TestPatienceDiffLibFiles): class TestPatienceDiffLibFiles_c(TestPatienceDiffLibFiles):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment