~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_multiparent.py

(vila) Forbid more operations on ReadonlyTransportDecorator (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2007, 2009, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
from unittest import TestCase
18
18
 
19
19
from bzrlib import (
20
 
    knit,
21
20
    multiparent,
22
21
    patiencediff,
23
22
    tests,
49
48
                          multiparent.ParentText(0, 1, 2, 3)],
50
49
                         diff.hunks)
51
50
 
 
51
        diff = multiparent.MultiParent.from_lines(LINES_2, [LINES_1])
 
52
        self.assertEqual([multiparent.ParentText(0, 0, 0, 1),
 
53
                          multiparent.ParentText(0, 2, 1, 3)],
 
54
                         diff.hunks)
 
55
 
52
56
    def test_compare_two_parents(self):
53
57
        diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3])
54
58
        self.assertEqual([multiparent.ParentText(1, 0, 0, 4),
64
68
                          multiparent.ParentText(0, 3, 4, 1)],
65
69
                         diff.hunks)
66
70
 
 
71
    def test_get_matching_blocks(self):
 
72
        diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2])
 
73
        self.assertEqual([(0, 0, 1), (1, 2, 3), (4, 5, 0)],
 
74
                         list(diff.get_matching_blocks(0, len(LINES_2))))
 
75
 
 
76
        diff = multiparent.MultiParent.from_lines(LINES_2, [LINES_1])
 
77
        self.assertEqual([(0, 0, 1), (2, 1, 3), (5, 4, 0)],
 
78
                         list(diff.get_matching_blocks(0, len(LINES_1))))
 
79
 
67
80
    def test_range_iterator(self):
68
81
        diff = multiparent.MultiParent.from_lines(LINES_1, [LINES_2, LINES_3])
69
82
        diff.hunks.append(multiparent.NewText(['q\n']))
252
265
    def test_filenames(self):
253
266
        vf = multiparent.MultiVersionedFile('foop')
254
267
        vf.add_version('a\nb\nc\nd'.splitlines(True), 'a', [])
255
 
        self.failUnlessExists('foop.mpknit')
256
 
        self.failIfExists('foop.mpidx')
 
268
        self.assertPathExists('foop.mpknit')
 
269
        self.assertPathDoesNotExist('foop.mpidx')
257
270
        vf.save()
258
 
        self.failUnlessExists('foop.mpidx')
 
271
        self.assertPathExists('foop.mpidx')
259
272
        vf.destroy()
260
 
        self.failIfExists('foop.mpknit')
261
 
        self.failIfExists('foop.mpidx')
 
273
        self.assertPathDoesNotExist('foop.mpknit')
 
274
        self.assertPathDoesNotExist('foop.mpidx')