~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf_ui.py

  • Committer: John Arbash Meinel
  • Date: 2011-01-12 21:27:00 UTC
  • mto: This revision was merged to the branch mainline in revision 5605.
  • Revision ID: john@arbash-meinel.com-20110112212700-esqmtrmevddxrsq2
Clean up the test slightly, hoping to avoid race conditions, update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
LINES_AY = 'a\nb\nc\nd\ne\nf\ng\nh\ni\ny\n'
64
64
 
65
65
 
66
 
class ShelfTestCase(tests.TestCaseWithTransport):
 
66
class TestShelver(tests.TestCaseWithTransport):
67
67
 
68
68
    def create_shelvable_tree(self):
69
69
        tree = self.make_branch_and_tree('tree')
73
73
        self.build_tree_contents([('tree/foo', LINES_ZY)])
74
74
        return tree
75
75
 
76
 
 
77
 
class TestShelver(ShelfTestCase):
78
 
 
79
76
    def test_unexpected_prompt_failure(self):
80
77
        tree = self.create_shelvable_tree()
81
78
        tree.lock_tree_write()
193
190
        shelver.expect('Shelve adding file "foo"? [yNfq?]', 'y')
194
191
        shelver.expect('Shelve 1 change(s)? [yNfq?]', 'y')
195
192
        shelver.run()
196
 
        self.assertPathDoesNotExist('tree/foo')
 
193
        self.failIfExists('tree/foo')
197
194
 
198
195
    def test_shelve_kind_change(self):
199
196
        tree = self.create_shelvable_tree()
302
299
        finally:
303
300
            tree.unlock()
304
301
 
305
 
    def test_shelve_old_root_preserved(self):
 
302
    def test_shelve_old_root_deleted(self):
306
303
        tree1 = self.make_branch_and_tree('tree1')
307
304
        tree1.commit('add root')
308
 
        tree1_root_id = tree1.get_root_id()
309
305
        tree2 = self.make_branch_and_tree('tree2')
310
306
        rev2 = tree2.commit('add root')
311
 
        self.assertNotEquals(tree1_root_id, tree2.get_root_id())
312
307
        tree1.merge_from_branch(tree2.branch,
313
308
                                from_revision=revision.NULL_REVISION)
314
 
        tree1.commit('merging in tree2')
315
 
        self.assertEquals(tree1_root_id, tree1.get_root_id())
 
309
        tree1.commit('Replaced root entry')
316
310
        # This is essentially assertNotRaises(InconsistentDelta)
317
 
        # With testtools 0.9.9, it can be rewritten as:
318
 
        # with ExpectedException(AssertionError,
319
 
        #                        'InconsistentDelta not raised'):
320
 
        #     with ExpectedException(errors.InconsistentDelta, ''):
321
 
        #         self.shelve_all(tree1, rev2)
322
 
        e = self.assertRaises(AssertionError, self.assertRaises,
323
 
                              errors.InconsistentDelta, self.shelve_all, tree1,
324
 
                              rev2)
325
 
        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)
326
315
 
327
316
    def test_shelve_split(self):
328
317
        outer_tree = self.make_branch_and_tree('outer')
338
327
                           outer_tree, rev2)
339
328
 
340
329
 
341
 
class TestApplyReporter(ShelfTestCase):
 
330
class TestApplyReporter(TestShelver):
342
331
 
343
332
    def test_shelve_not_diff(self):
344
333
        tree = self.create_shelvable_tree()
433
422
        shelver.expect('Delete file "foo"? [yNfq?]', 'y')
434
423
        shelver.expect('Apply 1 change(s)? [yNfq?]', 'y')
435
424
        shelver.run()
436
 
        self.assertPathDoesNotExist('tree/foo')
 
425
        self.failIfExists('tree/foo')
437
426
 
438
427
    def test_shelve_kind_change(self):
439
428
        tree = self.create_shelvable_tree()