~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Jelmer Vernooij
  • Date: 2012-02-20 14:15:25 UTC
  • mto: (6471.1.4 iter-child-entries)
  • mto: This revision was merged to the branch mainline in revision 6472.
  • Revision ID: jelmer@samba.org-20120220141525-9azkfei62st8yc7w
Use inventories directly in fewer places.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3674
3674
        self.assertEquals('bar', conf.get('foo'))
3675
3675
 
3676
3676
 
3677
 
class TestStackIterSections(tests.TestCase):
3678
 
 
3679
 
    def test_empty_stack(self):
3680
 
        conf = config.Stack([])
3681
 
        sections = list(conf.iter_sections())
3682
 
        self.assertLength(0, sections)
3683
 
 
3684
 
    def test_empty_store(self):
3685
 
        store = config.IniFileStore()
3686
 
        store._load_from_string('')
3687
 
        conf = config.Stack([store.get_sections])
3688
 
        sections = list(conf.iter_sections())
3689
 
        self.assertLength(0, sections)
3690
 
 
3691
 
    def test_simple_store(self):
3692
 
        store = config.IniFileStore()
3693
 
        store._load_from_string('foo=bar')
3694
 
        conf = config.Stack([store.get_sections])
3695
 
        tuples = list(conf.iter_sections())
3696
 
        self.assertLength(1, tuples)
3697
 
        (found_store, found_section) = tuples[0]
3698
 
        self.assertIs(store, found_store)
3699
 
 
3700
 
    def test_two_stores(self):
3701
 
        store1 = config.IniFileStore()
3702
 
        store1._load_from_string('foo=bar')
3703
 
        store2 = config.IniFileStore()
3704
 
        store2._load_from_string('bar=qux')
3705
 
        conf = config.Stack([store1.get_sections, store2.get_sections])
3706
 
        tuples = list(conf.iter_sections())
3707
 
        self.assertLength(2, tuples)
3708
 
        self.assertIs(store1, tuples[0][0])
3709
 
        self.assertIs(store2, tuples[1][0])
3710
 
 
3711
 
 
3712
3677
class TestStackWithTransport(tests.TestCaseWithTransport):
3713
3678
 
3714
3679
    scenarios = [(key, {'get_stack': builder}) for key, builder
3994
3959
baz=end
3995
3960
list={foo}
3996
3961
''')
3997
 
        self.registry.register(config.ListOption('list'))
3998
 
        # Register an intermediate option as a list to ensure no conversion
3999
 
        # happen while expanding. Conversion should only occur for the original
4000
 
        # option ('list' here).
4001
 
        self.registry.register(config.ListOption('baz'))
 
3962
        self.registry.register(
 
3963
            config.ListOption('list'))
4002
3964
        self.assertEquals(['start', 'middle', 'end'],
4003
3965
                           self.conf.get('list', expand=True))
4004
3966