forked from FabriceSalvaire/CodeReview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_RawTextDocumentDiff.py
More file actions
78 lines (51 loc) · 2.47 KB
/
test_RawTextDocumentDiff.py
File metadata and controls
78 lines (51 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
####################################################################################################
import os
import unittest
####################################################################################################
from CodeReview.Diff.RawTextDocument import RawTextDocument
from CodeReview.Diff.RawTextDocumentDiff import TwoWayFileDiffFactory
####################################################################################################
class TestRawTextDocumentDiff(unittest.TestCase):
##############################################
@staticmethod
def _join_data_path(filename):
return os.path.join(os.path.dirname(__file__), 'data', filename)
##############################################
@unittest.skip
def test(self):
with open(self._join_data_path('test_file1.py')) as f:
text1 = f.read()
with open(self._join_data_path('test_file2.py')) as f:
text2 = f.read()
raw_text_document1 = RawTextDocument(text1)
raw_text_document2 = RawTextDocument(text2)
two_way_file_diff_factory = TwoWayFileDiffFactory()
file_diff = two_way_file_diff_factory.process(raw_text_document1, raw_text_document2)
file_diff.pretty_print()
file_diff.print_unidiff()
print('='*10)
replace_group = file_diff[1]
print(replace_group)
print(replace_group[1].chunk1)
print(list(replace_group[1].chunk1.line_iterator()))
print(list(replace_group[1].chunk2.line_iterator()))
print(list(replace_group[1].chunk1.line_slice_iterator()))
##############################################
def test_empty(self):
text1 = ''
with open(self._join_data_path('test_file2.py')) as f:
text2 = f.read()
raw_text_document1 = RawTextDocument(text1)
raw_text_document2 = RawTextDocument(text2)
two_way_file_diff_factory = TwoWayFileDiffFactory()
file_diff = two_way_file_diff_factory.process(raw_text_document1, raw_text_document2)
file_diff.pretty_print()
file_diff.print_unidiff()
####################################################################################################
if __name__ == '__main__':
unittest.main()
####################################################################################################
#
# End
#
####################################################################################################