~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: Martin
  • Date: 2011-05-21 16:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5907.
  • Revision ID: gzlist@googlemail.com-20110521162938-1vrw3hp0197l3vrl
Add tests for non-ascii conflict serialisation

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    tests,
28
28
)
29
29
from bzrlib.tests import script
30
 
from bzrlib.tests import (
31
 
    features,
32
 
    )
33
30
 
34
31
 
35
32
class ExpectShelver(shelf_ui.Shelver):
66
63
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n'
67
64
 
68
65
 
69
 
class ShelfTestCase(tests.TestCaseWithTransport):
 
66
class TestShelver(tests.TestCaseWithTransport):
70
67
 
71
68
    def create_shelvable_tree(self):
72
69
        tree = self.make_branch_and_tree('tree')
76
73
        self.build_tree_contents([('tree/foo', LINES_ZY)])
77
74
        return tree
78
75
 
79
 
 
80
 
class TestShelver(ShelfTestCase):
81
 
 
82
76
    def test_unexpected_prompt_failure(self):
83
77
        tree = self.create_shelvable_tree()
84
78
        tree.lock_tree_write()
211
205
        shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
212
206
 
213
207
    def test_shelve_modify_target(self):
214
 
        self.requireFeature(features.SymlinkFeature)
 
208
        self.requireFeature(tests.SymlinkFeature)
215
209
        tree = self.create_shelvable_tree()
216
210
        os.symlink('bar', 'tree/baz')
217
211
        tree.add('baz', 'baz-id')
305
299
        finally:
306
300
            tree.unlock()
307
301
 
308
 
    def test_shelve_old_root_preserved(self):
 
302
    def test_shelve_old_root_deleted(self):
309
303
        tree1 = self.make_branch_and_tree('tree1')
310
304
        tree1.commit('add root')
311
 
        tree1_root_id = tree1.get_root_id()
312
305
        tree2 = self.make_branch_and_tree('tree2')
313
306
        rev2 = tree2.commit('add root')
314
 
        self.assertNotEquals(tree1_root_id, tree2.get_root_id())
315
307
        tree1.merge_from_branch(tree2.branch,
316
308
                                from_revision=revision.NULL_REVISION)
317
 
        tree1.commit('merging in tree2')
318
 
        self.assertEquals(tree1_root_id, tree1.get_root_id())
 
309
        tree1.commit('Replaced root entry')
319
310
        # This is essentially assertNotRaises(InconsistentDelta)
320
 
        # With testtools 0.9.9, it can be rewritten as:
321
 
        # with ExpectedException(AssertionError,
322
 
        #                        'InconsistentDelta not raised'):
323
 
        #     with ExpectedException(errors.InconsistentDelta, ''):
324
 
        #         self.shelve_all(tree1, rev2)
325
 
        e = self.assertRaises(AssertionError, self.assertRaises,
326
 
                              errors.InconsistentDelta, self.shelve_all, tree1,
327
 
                              rev2)
328
 
        self.assertContainsRe('InconsistentDelta not raised', str(e))
 
311
        self.expectFailure('Cannot shelve replacing a root entry',
 
312
                           self.assertRaises, AssertionError,
 
313
                           self.assertRaises, errors.InconsistentDelta,
 
314
                           self.shelve_all, tree1, rev2)
329
315
 
330
316
    def test_shelve_split(self):
331
317
        outer_tree = self.make_branch_and_tree('outer')
341
327
                           outer_tree, rev2)
342
328
 
343
329
 
344
 
class TestApplyReporter(ShelfTestCase):
 
330
class TestApplyReporter(TestShelver):
345
331
 
346
332
    def test_shelve_not_diff(self):
347
333
        tree = self.create_shelvable_tree()
451
437
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
452
438
 
453
439
    def test_shelve_modify_target(self):
454
 
        self.requireFeature(features.SymlinkFeature)
 
440
        self.requireFeature(tests.SymlinkFeature)
455
441
        tree = self.create_shelvable_tree()
456
442
        os.symlink('bar', 'tree/baz')
457
443
        tree.add('baz', 'baz-id')