# Bazaar revision bundle v0.8 # # message: # TreeConfig should support sections # # simple fix and tests # # committer: Jan Balster # date: Wed 2006-07-26 01:20:26.188999891 +0200 === modified file bzrlib/config.py --- bzrlib/config.py +++ bzrlib/config.py @@ -722,7 +722,7 @@ obj = self._get_config() try: if section is not None: - obj[section] + obj = obj[section] result = obj[name] except KeyError: result = default === modified file bzrlib/tests/test_config.py --- bzrlib/tests/test_config.py +++ bzrlib/tests/test_config.py @@ -118,6 +118,9 @@ def lock_write(self): pass + def lock_read(self): + pass + def unlock(self): pass @@ -818,6 +821,24 @@ location='http://example.com/specific') self.assertEqual(my_config.get_user_option('option'), 'exact') +class TestTreeConfig(TestCaseInTempDir): + + def test_toplevel_key(self): + branch = FakeBranch(user_id='Robert Collins ') + my_config = config.TreeConfig(branch) + my_config.set_option('myvalue', 'myname') + self.assertEqual(my_config.get_option('myname', default='default_value'), + 'myvalue') + + + def test_supports_sections(self): + branch = FakeBranch(user_id='Robert Collins ') + my_config = config.TreeConfig(branch) + my_config.set_option('myvalue', 'myname', 'mysection') + self.assertEqual(my_config.get_option('myname', 'mysection', + 'default_value'), 'myvalue') + + class TestMailAddressExtraction(TestCase): # revision id: jan@merlinux.de-20060725232026-37d4c98561d1f4c8 # sha1: 9b04dadfeb9e006e5c115495440e99518bce2032 # inventory sha1: 581805817e57e3882e67195386fb17459003a4d7 # parent ids: # pqm@pqm.ubuntu.com-20060725135859-f810b8a9929427a5 # base id: pqm@pqm.ubuntu.com-20060725135859-f810b8a9929427a5 # properties: # branch-nick: bzr.dev