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 |
|
50 |
||
51 |
class TestNewText(TestCase): |
|
52 |
||
53 |
def test_eq(self): |
|
54 |
self.assertEqual(multiparent.NewText([]), multiparent.NewText([])) |
|
55 |
self.assertFalse(multiparent.NewText(['a']) == |
|
56 |
multiparent.NewText(['b'])) |
|
|
0.9.2
by Aaron Bentley
Get single-parent comparison working |
57 |
self.assertFalse(multiparent.NewText(['a']) == Mock(lines=['a'])) |
58 |
||
59 |
||
60 |
class TestParentText(TestCase): |
|
61 |
||
62 |
def test_eq(self): |
|
63 |
self.assertEqual(multiparent.ParentText(1, 2, 3, 4), |
|
64 |
multiparent.ParentText(1, 2, 3, 4)) |
|
65 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
66 |
multiparent.ParentText(2, 2, 3, 4)) |
|
67 |
||
68 |
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) == |
|
69 |
Mock(parent=1, parent_pos=2, child_pos=3, |
|
70 |
num_lines=4)) |