bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.9.1
by Aaron Bentley
Get trivial case passing |
1 |
from unittest import TestCase |
2 |
||
3 |
import multiparent |
|
4 |
||
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
5 |
|
|
0.9.1
by Aaron Bentley
Get trivial case passing |
6 |
LINES_1 = "a\nb\nc\nd\ne\n".splitlines(True) |
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
7 |
LINES_2 = "a\nc\nd\ne\n".splitlines(True) |
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
8 |
LINES_3 = "a\nb\nc\nd\n".splitlines(True) |
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
9 |
|
10 |
||
11 |
class Mock(object): |
|
12 |
||
13 |
def __init__(self, **kwargs): |
|
14 |
self.__dict__ = kwargs |
|
15 |
||
|
0.9.1
by Aaron Bentley
Get trivial case passing |
16 |
|
17 |
class TestMulti(TestCase): |
|
18 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
19 |
def test_compare_no_parent(self): |
20 |
diff = multiparent.MultiParent.from_lines(LINES_1) |
|
21 |
self.assertEqual([multiparent.NewText(LINES_1)], diff.hunks) |
|
22 |
||
23 |
def test_compare_one_parent(self): |
|
24 |
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2]) |
|
25 |
self.assertEqual([multiparent.ParentText(0, 0, 0, 1), |
|
26 |
multiparent.NewText(['b\n']), |
|
27 |
multiparent.ParentText(0, 1, 2, 3)], |
|
28 |
diff.hunks) |
|
29 |
||
|
0.9.3
by Aaron Bentley
Get three-parent comparisions under test |
30 |
def test_compare_two_parents(self): |
31 |
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3]) |
|
32 |
self.assertEqual([multiparent.ParentText(1, 0, 0, 4), |
|
33 |
multiparent.ParentText(0, 3, 4, 1)], |
|
34 |
diff.hunks) |
|
35 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
36 |
def test_eq(self): |
37 |
diff = multiparent.MultiParent.from_lines(LINES_1) |
|
38 |
diff2 = multiparent.MultiParent.from_lines(LINES_1) |
|
39 |
self.assertEqual(diff, diff2) |
|
40 |
diff3 = multiparent.MultiParent.from_lines(LINES_2) |
|
41 |
self.assertFalse(diff == diff3) |
|
42 |
self.assertFalse(diff == Mock(hunks=[multiparent.NewText(LINES_1)])) |
|
43 |
self.assertEqual(multiparent.MultiParent( |
|
44 |
[multiparent.NewText(LINES_1), |
|
45 |
multiparent.ParentText(0, 1, 2, 3)]), |
|
46 |
multiparent.MultiParent( |
|
47 |
[multiparent.NewText(LINES_1), |
|
48 |
multiparent.ParentText(0, 1, 2, 3)])) |
|
|
0.9.1
by Aaron Bentley
Get trivial case passing |
49 |
|
|
0.9.4
by Aaron Bentley
Start supporting serialization |
50 |
def test_to_patch(self): |
51 |
self.assertEqual(['i 1\n', 'a\n', '\n', 'c 0 1 2 3\n'], |
|
52 |
list(multiparent.MultiParent([multiparent.NewText(['a\n']), |
|
53 |
multiparent.ParentText(0, 1, 2, 3)]).to_patch())) |
|
54 |
||
|
0.9.1
by Aaron Bentley
Get trivial case passing |
55 |
|
56 |
class TestNewText(TestCase): |
|
57 |
||
58 |
def test_eq(self): |
|
59 |
self.assertEqual(multiparent.NewText([]), multiparent.NewText([])) |
|
60 |
self.assertFalse(multiparent.NewText(['a']) == |
|
61 |
multiparent.NewText(['b'])) |
|
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
62 |
self.assertFalse(multiparent.NewText(['a']) == Mock(lines=['a'])) |
63 |
||
|
0.9.4
by Aaron Bentley
Start supporting serialization |
64 |
def test_to_patch(self): |
65 |
self.assertEqual(['i 0\n', '\n'], |
|
66 |
list(multiparent.NewText([]).to_patch())) |
|
67 |
self.assertEqual(['i 1\n', 'a', '\n'], |
|
68 |
list(multiparent.NewText(['a']).to_patch())) |
|
69 |
self.assertEqual(['i 1\n', 'a\n', '\n'], |
|
70 |
list(multiparent.NewText(['a\n']).to_patch())) |
|
71 |
||
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
72 |
|
73 |
class TestParentText(TestCase): |
|
74 |
||
75 |
def test_eq(self): |
|
76 |
self.assertEqual(multiparent.ParentText(1, 2, 3, 4), |
|
77 |
multiparent.ParentText(1, 2, 3, 4)) |
|
78 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
79 |
multiparent.ParentText(2, 2, 3, 4)) |
|
80 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
81 |
Mock(parent=1, parent_pos=2, child_pos=3, |
|
82 |
num_lines=4)) |
|
|
0.9.4
by Aaron Bentley
Start supporting serialization |
83 |
|
84 |
def test_to_patch(self): |
|
85 |
self.assertEqual(['c 0 1 2 3\n'], |
|
86 |
list(multiparent.ParentText(0, 1, 2, 3).to_patch())) |