~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Vincent Ladeuil
  • Date: 2012-02-20 17:08:34 UTC
  • mto: This revision was merged to the branch mainline in revision 6471.
  • Revision ID: v.ladeuil+lp@free.fr-20120220170834-q078ypyk84eb9ng3
Fix typo and add tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3640
3640
        self.assertEquals('bar', conf.get('foo'))
3641
3641
 
3642
3642
 
 
3643
class TestStackIterSections(tests.TestCase):
 
3644
 
 
3645
    def test_empty_stack(self):
 
3646
        conf = config.Stack([])
 
3647
        sections = list(conf.iter_sections())
 
3648
        self.assertLength(0, sections)
 
3649
 
 
3650
    def test_empty_store(self):
 
3651
        store = config.IniFileStore()
 
3652
        store._load_from_string('')
 
3653
        conf = config.Stack([store.get_sections])
 
3654
        sections = list(conf.iter_sections())
 
3655
        self.assertLength(0, sections)
 
3656
 
 
3657
    def test_simple_store(self):
 
3658
        store = config.IniFileStore()
 
3659
        store._load_from_string('foo=bar')
 
3660
        conf = config.Stack([store.get_sections])
 
3661
        tuples = list(conf.iter_sections())
 
3662
        self.assertLength(1, tuples)
 
3663
        (found_store, found_section) = tuples[0]
 
3664
        self.assertIs(store, found_store)
 
3665
 
 
3666
    def test_two_stores(self):
 
3667
        store1 = config.IniFileStore()
 
3668
        store1._load_from_string('foo=bar')
 
3669
        store2 = config.IniFileStore()
 
3670
        store2._load_from_string('bar=qux')
 
3671
        conf = config.Stack([store1.get_sections, store2.get_sections])
 
3672
        tuples = list(conf.iter_sections())
 
3673
        self.assertLength(2, tuples)
 
3674
        self.assertIs(store1, tuples[0][0])
 
3675
        self.assertIs(store2, tuples[1][0])
 
3676
 
 
3677
 
3643
3678
class TestStackWithTransport(tests.TestCaseWithTransport):
3644
3679
 
3645
3680
    scenarios = [(key, {'get_stack': builder}) for key, builder
3926
3961
''')
3927
3962
        self.registry.register(config.ListOption('list'))
3928
3963
        # Register an intermediate option as a list to ensure no conversion
3929
 
        # happen while expanding. Conversion should only occur for the origianl
 
3964
        # happen while expanding. Conversion should only occur for the original
3930
3965
        # option ('list' here).
3931
3966
        self.registry.register(config.ListOption('baz'))
3932
3967
        self.assertEquals(['start', 'middle', 'end'],