~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_status.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    conflicts,
34
34
    errors,
35
35
    osutils,
 
36
    status,
36
37
    )
37
38
import bzrlib.branch
38
39
from bzrlib.osutils import pathjoin
44
45
 
45
46
class BranchStatus(TestCaseWithTransport):
46
47
 
 
48
    def setUp(self):
 
49
        super(BranchStatus, self).setUp()
 
50
        # As TestCase.setUp clears all hooks, we install this default
 
51
        # post_status hook handler for the test.
 
52
        status.hooks.install_named_hook('post_status',
 
53
            status._show_shelve_summary,
 
54
            'bzr status')
 
55
 
47
56
    def assertStatus(self, expected_lines, working_tree,
48
57
        revision=None, short=False, pending=True, verbose=False):
49
58
        """Run status in working_tree and look for output.
202
211
        wt = self.make_branch_and_tree('.')
203
212
        b = wt.branch
204
213
 
205
 
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
 
214
        self.build_tree(['directory/','directory/hello.c',
 
215
                         'bye.c','test.c','dir2/',
 
216
                         'missing.c'])
206
217
        wt.add('directory')
207
218
        wt.add('test.c')
208
219
        wt.commit('testing')
 
220
        wt.add('missing.c')
 
221
        unlink('missing.c')
209
222
 
210
223
        self.assertStatus([
 
224
                'missing:\n',
 
225
                '  missing.c\n',
211
226
                'unknown:\n',
212
227
                '  bye.c\n',
213
228
                '  dir2/\n',
218
233
        self.assertStatus([
219
234
                '?   bye.c\n',
220
235
                '?   dir2/\n',
 
236
                '+!  missing.c\n',
221
237
                '?   directory/hello.c\n'
222
238
                ],
223
239
                wt, short=True)
260
276
        tof.seek(0)
261
277
        self.assertEquals(tof.readlines(), ['+N  test.c\n'])
262
278
 
 
279
        tof = StringIO()
 
280
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof)
 
281
        tof.seek(0)
 
282
        self.assertEquals(tof.readlines(),
 
283
                          ['missing:\n',
 
284
                           '  missing.c\n'])
 
285
 
 
286
        tof = StringIO()
 
287
        show_tree_status(wt, specific_files=['missing.c'], to_file=tof,
 
288
                         short=True)
 
289
        tof.seek(0)
 
290
        self.assertEquals(tof.readlines(),
 
291
                          ['+!  missing.c\n'])
 
292
 
263
293
    def test_specific_files_conflicts(self):
264
294
        tree = self.make_branch_and_tree('.')
265
295
        self.build_tree(['dir2/'])
520
550
        out, err = self.run_bzr('status branch1 -rbranch:branch2')
521
551
        self.assertEqual('', out)
522
552
 
 
553
    def test_status_with_shelves(self):
 
554
        """Ensure that _show_shelve_summary handler works.
 
555
        """
 
556
        wt = self.make_branch_and_tree('.')
 
557
        self.build_tree(['hello.c'])
 
558
        wt.add('hello.c')
 
559
        self.run_bzr(['shelve', '--all', '-m', 'foo'])
 
560
        self.build_tree(['bye.c'])
 
561
        wt.add('bye.c')
 
562
        self.assertStatus([
 
563
                'added:\n',
 
564
                '  bye.c\n',
 
565
                '1 shelf exists. See "bzr shelve --list" for details.\n',
 
566
            ],
 
567
            wt)
 
568
        self.run_bzr(['shelve', '--all', '-m', 'bar'])
 
569
        self.build_tree(['spam.c'])
 
570
        wt.add('spam.c')
 
571
        self.assertStatus([
 
572
                'added:\n',
 
573
                '  spam.c\n',
 
574
                '2 shelves exist. See "bzr shelve --list" for details.\n',
 
575
            ],
 
576
            wt)
 
577
 
523
578
 
524
579
class CheckoutStatus(BranchStatus):
525
580