3640
3640
self.assertEquals('bar', conf.get('foo'))
3643
class TestStackIterSections(tests.TestCase):
3645
def test_empty_stack(self):
3646
conf = config.Stack([])
3647
sections = list(conf.iter_sections())
3648
self.assertLength(0, sections)
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)
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)
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])
3643
3678
class TestStackWithTransport(tests.TestCaseWithTransport):
3645
3680
scenarios = [(key, {'get_stack': builder}) for key, builder
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'],