~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

(vila) Fix RegistryOption display in bzr config output (Vincent Ladeuil)

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
 
3677
3712
class TestStackWithTransport(tests.TestCaseWithTransport):
3678
3713
 
3679
3714
    scenarios = [(key, {'get_stack': builder}) for key, builder
3959
3994
baz=end
3960
3995
list={foo}
3961
3996
''')
3962
 
        self.registry.register(
3963
 
            config.ListOption('list'))
 
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'))
3964
4002
        self.assertEquals(['start', 'middle', 'end'],
3965
4003
                           self.conf.get('list', expand=True))
3966
4004