~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-04-23 08:35:38 UTC
  • mfrom: (5176.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100423083538-2fokv22a7e596kmb
(vila) Warn if a config variable can't be interpreted as a boolean

Show diffs side-by-side

added added

removed removed

Lines of Context:
406
406
        get_bool = conf.get_user_option_as_bool
407
407
        self.assertEqual(True, get_bool('a_true_bool'))
408
408
        self.assertEqual(False, get_bool('a_false_bool'))
 
409
        warnings = []
 
410
        def warning(*args):
 
411
            warnings.append(args[0] % args[1:])
 
412
        self.overrideAttr(trace, 'warning', warning)
 
413
        msg = 'Value "%s" is not a boolean for "%s"'
409
414
        self.assertIs(None, get_bool('an_invalid_bool'))
 
415
        self.assertEquals(msg % ('maybe', 'an_invalid_bool'), warnings[0])
 
416
        warnings = []
410
417
        self.assertIs(None, get_bool('not_defined_in_this_config'))
411
 
 
 
418
        self.assertEquals([], warnings)
412
419
 
413
420
    def test_get_user_option_as_list(self):
414
421
        conf, parser = self.make_config_parser("""