Rev 5751: Slight refactoring. in file:///home/vila/src/bzr/experimental/config/

Vincent Ladeuil v.ladeuil+lp at free.fr
Mon Apr 4 13:03:12 UTC 2011


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

------------------------------------------------------------
revno: 5751
revision-id: v.ladeuil+lp at free.fr-20110404130312-nyt1lpkuustnnqq3
parent: v.ladeuil+lp at free.fr-20110404121257-m4htb561v7b4c2ur
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-store
timestamp: Mon 2011-04-04 15:03:12 +0200
message:
  Slight refactoring.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py	2011-04-04 12:12:57 +0000
+++ b/bzrlib/config.py	2011-04-04 13:03:12 +0000
@@ -2072,8 +2072,7 @@
         return conf
 
     def _create_from_string(self, str_or_unicode, save):
-        # We just keep record the content waiting for load() to be called when
-        # needed
+        # We just keep the content waiting for load() to be called when needed
         self._content = StringIO(str_or_unicode.encode('utf-8'))
         # Some tests use in-memory configs, some other always need the config
         # file to exist on disk.

=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py	2011-04-04 12:12:57 +0000
+++ b/bzrlib/tests/test_config.py	2011-04-04 13:03:12 +0000
@@ -1893,16 +1893,25 @@
 
     # FIXME: parametrize against all valid (store, transport) combinations
 
+    def get_store(self, content=None, name=None):
+        if name is None:
+            name = 'foo.conf'
+        if content is None:
+            store = config.ConfigObjStore(self.get_transport(), name)
+        else:
+            store = config.ConfigObjStore.from_string(
+                content, self.get_transport(), name)
+        return store
+
     def test_delayed_load(self):
         self.build_tree_contents([('foo.conf', '')])
-        store = config.ConfigObjStore(self.get_transport(), 'foo.conf')
+        store = self.get_store(None, 'foo.conf')
         self.assertEquals(False, store.loaded)
         store.load()
         self.assertEquals(True, store.loaded)
 
     def test_from_string_delayed_load(self):
-        store = config.ConfigObjStore.from_string('',
-            self.get_transport(), 'foo.conf')
+        store = self.get_store('')
         self.assertEquals(False, store.loaded)
         store.load()
         self.assertEquals(True, store.loaded)
@@ -1910,8 +1919,7 @@
         self.failIfExists('foo.conf')
 
     def test_invalid_content(self):
-        self.build_tree_contents([('foo.conf', 'this is invalid !')])
-        store = config.ConfigObjStore(self.get_transport(), 'foo.conf')
+        store = self.get_store('this is invalid !', 'foo.conf')
         self.assertEquals(False, store.loaded)
         exc = self.assertRaises(errors.ParseConfigError, store.load)
         self.assertEndsWith(exc.filename, 'foo.conf')



More information about the bazaar-commits mailing list