~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_branch.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-23 07:03:49 UTC
  • mto: (5176.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5177.
  • Revision ID: v.ladeuil+lp@free.fr-20100423070349-a1teldjccr9xthwa
Fixed as per Andrew's review.

Show diffs side-by-side

added added

removed removed

Lines of Context:
497
497
        super(TestBranchOptions, self).setUp()
498
498
        self.branch = self.make_branch('.')
499
499
        self.config = self.branch.get_config()
500
 
        self.warnings = []
501
 
        def warning(*args):
502
 
            self.warnings.append(args[0] % args[1:])
503
 
        self.overrideAttr(trace, 'warning', warning)
504
500
 
505
 
    def check_aro_is(self, expected_value, value=None, check_warn=False):
 
501
    def check_append_revisions_only(self, expected_value, value=None):
 
502
        """Set append_revisions_only in config and check its interpretation."""
506
503
        if value is not None:
507
504
            self.config.set_user_option('append_revisions_only', value)
508
 
        if check_warn:
509
 
            self.warnings = []
510
505
        self.assertEqual(expected_value,
511
506
                         self.branch._get_append_revisions_only())
512
 
        if check_warn:
513
 
            msg = ('Value "%s" is not a boolean for "append_revisions_only"')
514
 
            self.assertLength(1, self.warnings)
515
 
            self.assertEqual(msg % value, self.warnings[0])
516
507
 
517
508
    def test_valid_append_revisions_only(self):
518
509
        self.assertEquals(None,
519
510
                          self.config.get_user_option('append_revisions_only'))
520
 
        self.check_aro_is(None)
521
 
        self.check_aro_is(False, 'False')
522
 
        self.check_aro_is(True, 'True')
 
511
        self.check_append_revisions_only(None)
 
512
        self.check_append_revisions_only(False, 'False')
 
513
        self.check_append_revisions_only(True, 'True')
523
514
        # The following values will cause compatibility problems on projects
524
515
        # using older bzr versions (<2.2) but are accepted
525
 
        self.check_aro_is(False, 'false')
526
 
        self.check_aro_is(True, 'true')
 
516
        self.check_append_revisions_only(False, 'false')
 
517
        self.check_append_revisions_only(True, 'true')
527
518
 
528
519
    def test_invalid_append_revisions_only(self):
529
520
        """Ensure warning is noted on invalid settings"""
530
 
        self.check_aro_is(None, 'not-a-bool', check_warn=True)
 
521
        self.warnings = []
 
522
        def warning(*args):
 
523
            self.warnings.append(args[0] % args[1:])
 
524
        self.overrideAttr(trace, 'warning', warning)
 
525
        self.check_append_revisions_only(None, 'not-a-bool')
 
526
        self.assertLength(1, self.warnings)
 
527
        self.assertEqual(
 
528
            'Value "not-a-bool" is not a boolean for "append_revisions_only"',
 
529
            self.warnings[0])
531
530
 
532
531
 
533
532
class TestPullResult(TestCase):