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

Vincent Ladeuil v.ladeuil+lp at free.fr
Tue Apr 12 11:39:44 UTC 2011


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

------------------------------------------------------------
revno: 5771 [merge]
revision-id: v.ladeuil+lp at free.fr-20110412113944-2n0f9q53b03hb5pk
parent: v.ladeuil+lp at free.fr-20110412112300-vzc4xjxttlrgel8j
parent: v.ladeuil+lp at free.fr-20110412113912-qovu9e021cye6eh6
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-concrete-stacks
timestamp: Tue 2011-04-12 13:39:44 +0200
message:
  Merge config-stack into config-concrete-stacks
modified:
  bzrlib/tests/test_config.py    testconfig.py-20051011041908-742d0c15d8d8c8eb
-------------- next part --------------
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-04-12 11:23:00 +0000
+++ b/bzrlib/tests/test_config.py	2011-04-12 11:39:44 +0000
@@ -1904,28 +1904,6 @@
         self.assertEquals(config._NewlyCreatedOption, section.orig['foo'])
 
 
-def get_ConfigObjStore(transport, file_name, content=None):
-    """Build a ConfigObjStore.
-
-    :param transport: The transport where the store lives.
-
-    :param file_name: The name of the store.
-
-    :param content: A provided content to inject into the built store.
-
-    If provided, the content is added to the store but without saving it on
-    disk. It should be a string or a unicode string in the ConfigObj syntax.
-    While this poses a constraint on other store implementations, it keeps a
-    simple syntax usable by test writers. Note that the other store
-    implementations can rely on ConfigObj to parse the content and get the
-    option definitions and values from it.
-    """
-    store = config.ConfigObjStore(transport, file_name)
-    if content is not None:
-        store._load_from_string(content)
-    return store
-
-
 class TestStore(tests.TestCaseWithTransport):
 
     def assertSectionContent(self, expected, section):
@@ -2127,34 +2105,21 @@
     # at possible fallouts for concurrent lockers -- vila 20110-04-06
 
 
-class TestConcreteConfigObjStores(tests.TestCaseWithTransport):
-
-    def test_global_store(self):
-        store = config.GlobalStore()
-
-    def test_location_store(self):
-        store = config.LocationStore()
-
-    def test_branch_store(self):
-        b = self.make_branch('.')
-        store = config.BranchStore(b)
-
-
 class TestSectionMatcher(TestStore):
 
     scenarios = [('location', {'matcher': config.LocationMatcher})]
 
-    def get_store(self, file_name, content=None):
-        return get_ConfigObjStore(
-            self.get_readonly_transport(), file_name, content=content)
+    def get_store(self, file_name):
+        return config.ConfigObjStore(self.get_readonly_transport(), file_name)
 
     def test_no_matches_for_empty_stores(self):
-        store = self.get_store('foo.conf', '')
+        store = self.get_store('foo.conf')
+        store._load_from_string('')
         matcher = self.matcher(store, '/bar')
         self.assertEquals([], list(matcher.get_sections()))
 
     def test_build_doesnt_load_store(self):
-        store = self.get_store('foo.conf', '')
+        store = self.get_store('foo.conf')
         matcher = self.matcher(store, '/bar')
         self.assertFalse(store.loaded)
 
@@ -2184,15 +2149,17 @@
 
 class TestLocationMatcher(TestStore):
 
+    def get_store(self, file_name):
+        return config.ConfigObjStore(self.get_readonly_transport(), file_name)
+
     def test_more_specific_sections_first(self):
-        store = config.ConfigObjStore.from_string(
-            '''
+        store = self.get_store('foo.conf')
+        store._load_from_string('''
 [/foo]
 section=/foo
 [/foo/bar]
 section=/foo/bar
-''',
-            self.get_readonly_transport(), 'foo.conf', )
+''')
         self.assertEquals(['/foo', '/foo/bar'],
                           [section.id for section in store.get_sections()])
         matcher = config.LocationMatcher(store, '/foo/bar/baz')
@@ -2242,8 +2209,8 @@
     # paramerized tests created to avoid bloating -- vila 2011-04-05
 
     def test_simple_set(self):
-        store = config.ConfigObjStore.from_string(
-            'foo=bar', self.get_transport(), 'test.conf')
+        store = config.ConfigObjStore(self.get_transport(), 'test.conf')
+        store._load_from_string('foo=bar')
         conf = config.ConfigStack(
             [store.get_sections], store.get_mutable_section)
         self.assertEquals('bar', conf.get('foo'))
@@ -2252,8 +2219,7 @@
         self.assertEquals('baz', conf.get('foo'))
 
     def test_set_creates_a_new_section(self):
-        store = config.ConfigObjStore.from_string(
-            '', self.get_transport(), 'test.conf')
+        store = config.ConfigObjStore(self.get_transport(), 'test.conf')
         conf = config.ConfigStack(
             [store.get_sections], store.get_mutable_section)
         conf.set('foo', 'baz')
@@ -2266,8 +2232,8 @@
     # paramerized tests created to avoid bloating -- vila 2011-04-06
 
     def test_remove_existing(self):
-        store = config.ConfigObjStore.from_string(
-            'foo=bar', self.get_transport(), 'test.conf')
+        store = config.ConfigObjStore(self.get_transport(), 'test.conf')
+        store._load_from_string('foo=bar')
         conf = config.ConfigStack(
             [store.get_sections], store.get_mutable_section)
         self.assertEquals('bar', conf.get('foo'))



More information about the bazaar-commits mailing list