1
1
# -*- coding: utf-8 -*-
2
- # test_basic.py
3
2
4
- from context import whatthepatch
3
+ import whatthepatch as wtp
5
4
6
- from whatthepatch import apply
7
5
8
6
import unittest
9
7
from io import StringIO
@@ -28,30 +26,30 @@ def test_diff_default(self):
28
26
with open ('tests/casefiles/diff-default.diff' ) as f :
29
27
diff_text = f .read ()
30
28
31
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
29
+ diff = [x for x in wtp .parse_patch (diff_text )]
32
30
diff = diff [0 ]
33
31
34
- new_text = apply .apply_diff (diff , self .lao )
32
+ new_text = wtp . apply .apply_diff (diff , self .lao )
35
33
self .assertEquals (new_text , self .tzu )
36
34
37
35
def test_diff_context (self ):
38
36
with open ('tests/casefiles/diff-context.diff' ) as f :
39
37
diff_text = f .read ()
40
38
41
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
39
+ diff = [x for x in wtp .parse_patch (diff_text )]
42
40
diff = diff [0 ]
43
41
44
- new_text = apply .apply_diff (diff , self .lao )
42
+ new_text = wtp . apply .apply_diff (diff , self .lao )
45
43
self .assertEquals (new_text , self .tzu )
46
44
47
45
def test_diff_unified (self ):
48
46
with open ('tests/casefiles/diff-unified.diff' ) as f :
49
47
diff_text = f .read ()
50
48
51
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
49
+ diff = [x for x in wtp .parse_patch (diff_text )]
52
50
diff = diff [0 ]
53
51
54
- new_text = apply .apply_diff (diff , self .lao )
52
+ new_text = wtp . apply .apply_diff (diff , self .lao )
55
53
for e in self .tzu :
56
54
print (e )
57
55
print ('~~~~' )
@@ -64,22 +62,22 @@ def test_diff_unified_patchutil(self):
64
62
with open ('tests/casefiles/diff-unified.diff' ) as f :
65
63
diff_text = f .read ()
66
64
67
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
65
+ diff = [x for x in wtp .parse_patch (diff_text )]
68
66
diff = diff [0 ]
69
67
70
- new_text = apply .apply_diff (diff , self .lao , use_patch = True )
68
+ new_text = wtp . apply .apply_diff (diff , self .lao , use_patch = True )
71
69
self .assertEquals (new_text , (self .tzu , None ))
72
70
73
- self .assertRaises (AssertionError , apply .apply_diff , diff , ['' ] + self .lao , use_patch = True )
71
+ self .assertRaises (AssertionError , wtp . apply .apply_diff , diff , ['' ] + self .lao , use_patch = True )
74
72
75
73
def test_diff_rcs (self ):
76
74
with open ('tests/casefiles/diff-rcs.diff' ) as f :
77
75
diff_text = f .read ()
78
76
79
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
77
+ diff = [x for x in wtp .parse_patch (diff_text )]
80
78
diff = diff [0 ]
81
79
82
- new_text = apply .apply_diff (diff , self .lao )
80
+ new_text = wtp . apply .apply_diff (diff , self .lao )
83
81
self .assertEquals (new_text , self .tzu )
84
82
85
83
def test_diff_ed (self ):
@@ -89,14 +87,14 @@ def test_diff_ed(self):
89
87
print (diff_text )
90
88
print (diff_text .splitlines ())
91
89
92
- diff = [x for x in whatthepatch .parse_patch (diff_text )]
90
+ diff = [x for x in wtp .parse_patch (diff_text )]
93
91
diff = diff [0 ]
94
92
95
93
print (diff )
96
- new_text = apply .apply_diff (diff , self .lao )
94
+ new_text = wtp . apply .apply_diff (diff , self .lao )
97
95
self .assertEquals (self .tzu ,new_text )
98
96
99
- new_text = apply .apply_diff (diff , self .lao , use_patch = True )
97
+ new_text = wtp . apply .apply_diff (diff , self .lao , use_patch = True )
100
98
self .assertEquals (new_text , (self .tzu , None ))
101
99
102
100
if __name__ == '__main__' :
0 commit comments