5
5
LINES_1 = "a\nb\nc\nd\ne\n".splitlines(True)
6
LINES_2 = "a\nc\nd\ne\n".splitlines(True)
11
def __init__(self, **kwargs):
12
self.__dict__ = kwargs
7
15
class TestMulti(TestCase):
9
def test_compare(self):
10
diff = multiparent.MultiParent.from_lines(LINES_1)
11
self.assertEqual(diff.hunks, [multiparent.NewText(LINES_1)])
17
def test_compare_no_parent(self):
18
diff = multiparent.MultiParent.from_lines(LINES_1)
19
self.assertEqual([multiparent.NewText(LINES_1)], diff.hunks)
21
def test_compare_one_parent(self):
22
diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2])
23
self.assertEqual([multiparent.ParentText(0, 0, 0, 1),
24
multiparent.NewText(['b\n']),
25
multiparent.ParentText(0, 1, 2, 3)],
29
diff = multiparent.MultiParent.from_lines(LINES_1)
30
diff2 = multiparent.MultiParent.from_lines(LINES_1)
31
self.assertEqual(diff, diff2)
32
diff3 = multiparent.MultiParent.from_lines(LINES_2)
33
self.assertFalse(diff == diff3)
34
self.assertFalse(diff == Mock(hunks=[multiparent.NewText(LINES_1)]))
35
self.assertEqual(multiparent.MultiParent(
36
[multiparent.NewText(LINES_1),
37
multiparent.ParentText(0, 1, 2, 3)]),
38
multiparent.MultiParent(
39
[multiparent.NewText(LINES_1),
40
multiparent.ParentText(0, 1, 2, 3)]))
14
43
class TestNewText(TestCase):
17
46
self.assertEqual(multiparent.NewText([]), multiparent.NewText([]))
18
47
self.assertFalse(multiparent.NewText(['a']) ==
19
48
multiparent.NewText(['b']))
20
class ThingWithLines(object):
23
self.assertFalse(multiparent.NewText(['a']) == ThingWithLines())
49
self.assertFalse(multiparent.NewText(['a']) == Mock(lines=['a']))
52
class TestParentText(TestCase):
55
self.assertEqual(multiparent.ParentText(1, 2, 3, 4),
56
multiparent.ParentText(1, 2, 3, 4))
57
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) ==
58
multiparent.ParentText(2, 2, 3, 4))
60
self.assertFalse(multiparent.ParentText(1, 2, 3, 4) ==
61
Mock(parent=1, parent_pos=2, child_pos=3,