Rev 5791: Puth the load hook in the right place. in file:///home/vila/src/bzr/experimental/config/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Jun 8 19:25:41 UTC 2011
At file:///home/vila/src/bzr/experimental/config/
------------------------------------------------------------
revno: 5791
revision-id: v.ladeuil+lp at free.fr-20110608192541-00cqtx1a0wv06pdc
parent: v.ladeuil+lp at free.fr-20110608171721-iwym6ng0rgndxuue
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: config-test-stats
timestamp: Wed 2011-06-08 21:25:41 +0200
message:
Puth the load hook in the right place.
-------------- next part --------------
=== modified file 'bzrlib/config.py'
--- a/bzrlib/config.py 2011-06-08 17:17:21 +0000
+++ b/bzrlib/config.py 2011-06-08 19:25:41 +0000
@@ -2272,6 +2272,8 @@
return
content = self.transport.get_bytes(self.file_name)
self._load_from_string(content)
+ for hook in Store.hooks['load']:
+ hook(self)
def _load_from_string(self, str_or_unicode):
"""Create a config store from a string.
@@ -2291,8 +2293,6 @@
except configobj.ConfigObjError, e:
self._config_obj = None
raise errors.ParseConfigError(e.errors, self.external_url())
- for hook in Store.hooks['load']:
- hook(self)
def save(self):
if not self.is_loaded():
=== modified file 'bzrlib/tests/test_config.py'
--- a/bzrlib/tests/test_config.py 2011-06-08 17:17:21 +0000
+++ b/bzrlib/tests/test_config.py 2011-06-08 19:25:41 +0000
@@ -2083,17 +2083,6 @@
store._load_from_string('foo=bar')
self.assertRaises(AssertionError, store._load_from_string, 'bar=baz')
- def test_load_hook(self):
- calls = []
- def hook(*args):
- calls.append(args)
- config.Store.hooks.install_named_hook('load', hook, None)
- self.assertLength(0, calls)
- store = self.get_store(self)
- store._load_from_string('')
- self.assertLength(1, calls)
- self.assertEquals((store,), calls[0])
-
class TestMutableStore(TestStore):
@@ -2178,6 +2167,23 @@
self.assertLength(1, sections)
self.assertSectionContent(('baz', {'foo': 'bar'}), sections[0])
+ def test_load_hook(self):
+ # We first needs to ensure that the store exists
+ store = self.get_store(self)
+ section = store.get_mutable_section('baz')
+ section.set('foo', 'bar')
+ store.save()
+ # Now we can try to load it
+ calls = []
+ def hook(*args):
+ calls.append(args)
+ config.Store.hooks.install_named_hook('load', hook, None)
+ self.assertLength(0, calls)
+ store = self.get_store(self)
+ store.load()
+ self.assertLength(1, calls)
+ self.assertEquals((store,), calls[0])
+
def test_save_hook(self):
calls = []
def hook(*args):
More information about the bazaar-commits
mailing list