~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Gordon Tyler
  • Date: 2010-01-14 15:24:04 UTC
  • mto: (5037.3.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5046.
  • Revision ID: gordon@doxxx.net-20100114152404-d64ik2afl96lcml0
Reverted changes to test_rules since the original should work now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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"'
414
409
        self.assertIs(None, get_bool('an_invalid_bool'))
415
 
        self.assertEquals(msg % ('maybe', 'an_invalid_bool'), warnings[0])
416
 
        warnings = []
417
410
        self.assertIs(None, get_bool('not_defined_in_this_config'))
418
 
        self.assertEquals([], warnings)
 
411
 
419
412
 
420
413
    def test_get_user_option_as_list(self):
421
414
        conf, parser = self.make_config_parser("""
1648
1641
        self.assertEquals(entered_password,
1649
1642
                          conf.get_password('ssh', 'bar.org', user='jim'))
1650
1643
        self.assertContainsRe(
1651
 
            self.get_log(),
 
1644
            self._get_log(keep_log_file=True),
1652
1645
            'password ignored in section \[ssh with password\]')
1653
1646
 
1654
1647
    def test_ssh_without_password_doesnt_emit_warning(self):
1673
1666
        # No warning shoud be emitted since there is no password. We are only
1674
1667
        # providing "user".
1675
1668
        self.assertNotContainsRe(
1676
 
            self.get_log(),
 
1669
            self._get_log(keep_log_file=True),
1677
1670
            'password ignored in section \[ssh with password\]')
1678
1671
 
1679
1672
    def test_uses_fallback_stores(self):
1680
 
        self.overrideAttr(config, 'credential_store_registry',
1681
 
                          config.CredentialStoreRegistry())
 
1673
        self._old_cs_registry = config.credential_store_registry
 
1674
        def restore():
 
1675
            config.credential_store_registry = self._old_cs_registry
 
1676
        self.addCleanup(restore)
 
1677
        config.credential_store_registry = config.CredentialStoreRegistry()
1682
1678
        store = StubCredentialStore()
1683
1679
        store.add_credentials("http", "example.com", "joe", "secret")
1684
1680
        config.credential_store_registry.register("stub", store, fallback=True)