Rev 5749: Merge config-concrete-stores into config-stack in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Apr 5 15:08:55 UTC 2011


At file:///home/vila/src/bzr/experimental/config/

------------------------------------------------------------
revno: 5749 [merge]
revision-id: v.ladeuil+lp at free.fr-20110405150855-kdf5y64v39qzrmbi
parent: v.ladeuil+lp at free.fr-20110405105422-mra9l3b1ltuaxchy
parent: v.ladeuil+lp at free.fr-20110405150853-e2yb8q99wpn08shf
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-stack
timestamp: Tue 2011-04-05 17:08:55 +0200
message:
  Merge config-concrete-stores into config-stack
modified:
  bzrlib/config.py               config.py-20051011043216-070c74f4e9e338e8
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-05 10:54:22 +0000
+++ b/bzrlib/config.py	2011-04-05 15:08:55 +0000
@@ -2125,9 +2125,9 @@
         self.load()
         cobj = self._config_obj
         if cobj.scalars:
-            yield None, dict([(k, cobj[k]) for k in cobj.scalars])
+            yield ReadOnlySection(None, cobj)
         for section_name in cobj.sections:
-            yield section_name, dict(cobj[section_name])
+            yield ReadOnlySection(section_name, cobj[section_name])
 
     def set_option(self, name, value, section_name=None):
         # We need a loaded store

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-04-05 10:54:22 +0000
+++ b/bzrlib/tests/test_config.py	2011-04-05 15:08:55 +0000
@@ -1947,21 +1947,30 @@
         store.load()
         self.assertEquals([], list(store.get_sections()))
 
+    def assertSectionContent(self, expected, section):
+        """Assert that some options have the proper values in a section."""
+        expected_name, expected_options = expected
+        self.assertEquals(expected_name, section.id)
+        self.assertEquals(
+            expected_options,
+            dict([(k, section.get(k)) for k in expected_options.keys()]))
+
     def test_get_default_section(self):
         store = self.get_store('foo.conf', 'foo=bar')
         sections = list(store.get_sections())
         self.assertLength(1, sections)
-        self.assertEquals((None, {'foo': 'bar'}), sections[0])
+        self.assertSectionContent((None, {'foo': 'bar'}), sections[0])
 
     def test_get_named_section(self):
         store = self.get_store('foo.conf', '[baz]\nfoo=bar')
         sections = list(store.get_sections())
         self.assertLength(1, sections)
-        self.assertEquals(('baz', {'foo': 'bar'}), sections[0])
+        self.assertSectionContent(('baz', {'foo': 'bar'}), sections[0])
 
     def test_get_embedded_sections(self):
         # A more complicated example (which also shows that section names and
         # option names share the same name space...)
+        # FIXME: This is really specific to ConfigObjStore -- vila 2011-04-05
         store = self.get_store('foo.conf', '''
 foo=bar
 l=1,2
@@ -1978,14 +1987,16 @@
         self.assertLength(4, sections)
         # The default section has no name.
         # List values are provided as lists
-        self.assertEquals((None, {'foo': 'bar', 'l': ['1', '2']}), sections[0])
-        self.assertEquals(('DEFAULT', {'foo_in_DEFAULT': 'foo_DEFAULT'}),
-                          sections[1])
-        self.assertEquals(('bar', {'foo_in_bar': 'barbar'}), sections[2])
+        self.assertSectionContent((None, {'foo': 'bar', 'l': ['1', '2']}),
+                                  sections[0])
+        self.assertSectionContent(
+            ('DEFAULT', {'foo_in_DEFAULT': 'foo_DEFAULT'}), sections[1])
+        self.assertSectionContent(
+            ('bar', {'foo_in_bar': 'barbar'}), sections[2])
         # sub sections are provided as embedded dicts.
-        self.assertEquals(('baz', {'foo_in_baz': 'barbaz',
-                                   'qux': {'foo_in_qux': 'quux'}}),
-                          sections[3])
+        self.assertSectionContent(
+            ('baz', {'foo_in_baz': 'barbaz', 'qux': {'foo_in_qux': 'quux'}}),
+            sections[3])
 
     def test_set_option_in_default_section(self):
         store = self.get_store('foo.conf', '')



More information about the bazaar-commits mailing list