Rev 4782: Hooks daughter classes should always call the base constructor in file:///home/vila/src/bzr/bugs/389648-hook-calls-base/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Tue Nov 3 09:32:17 GMT 2009
At file:///home/vila/src/bzr/bugs/389648-hook-calls-base/
------------------------------------------------------------
revno: 4782
revision-id: v.ladeuil+lp at free.fr-20091103093217-sodpsi6fzb36vk9y
parent: pqm at pqm.ubuntu.com-20091102110512-yw3aimu88nbmvoo9
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 389648-hook-calls-base
timestamp: Tue 2009-11-03 10:32:17 +0100
message:
Hooks daughter classes should always call the base constructor
* bzrlib/tests/test_hooks.py:
(TestHookRegistry.test_items_are_reasonable_keys): Reproduce bug
#389648 and ensures we won't regress again.
* bzrlib/version_info_formats/format_rio.py:
(RioVersionInfoBuilderHooks.__init__): Call base constructor.
* bzrlib/info.py:
(InfoHooks.__init__): Call base constructor.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS 2009-11-01 05:41:57 +0000
+++ b/NEWS 2009-11-03 09:32:17 +0000
@@ -21,6 +21,9 @@
Bug Fixes
*********
+* Hooks daughter classes should always call the base constructor.
+ (Alexander Belchenko, Vincent Ladeuil, #389648)
+
Improvements
************
=== modified file 'bzrlib/info.py'
--- a/bzrlib/info.py 2009-05-01 14:29:06 +0000
+++ b/bzrlib/info.py 2009-11-03 09:32:17 +0000
@@ -484,6 +484,7 @@
"""Hooks for the info command."""
def __init__(self):
+ super(InfoHooks, self).__init__()
self.create_hook(_mod_hooks.HookPoint('repository',
"Invoked when displaying the statistics for a repository. "
"repository is called with a statistics dictionary as returned "
=== modified file 'bzrlib/tests/test_hooks.py'
--- a/bzrlib/tests/test_hooks.py 2009-09-01 12:29:54 +0000
+++ b/bzrlib/tests/test_hooks.py 2009-11-03 09:32:17 +0000
@@ -16,7 +16,11 @@
"""Tests for the core Hooks logic."""
-from bzrlib import branch, errors
+from bzrlib import (
+ branch,
+ errors,
+ tests,
+ )
from bzrlib.hooks import (
HookPoint,
Hooks,
@@ -24,14 +28,9 @@
known_hooks_key_to_object,
known_hooks_key_to_parent_and_attribute,
)
-from bzrlib.errors import (
- UnknownHook,
- )
-
-from bzrlib.tests import TestCase
-
-
-class TestHooks(TestCase):
+
+
+class TestHooks(tests.TestCase):
def test_create_hook_first(self):
hooks = Hooks()
@@ -95,7 +94,7 @@
def test_install_named_hook_raises_unknown_hook(self):
hooks = Hooks()
- self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
+ self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',
None, "")
def test_install_named_hook_appends_known_hook(self):
@@ -111,7 +110,7 @@
self.assertEqual("demo", hooks.get_hook_name(None))
-class TestHook(TestCase):
+class TestHook(tests.TestCase):
def test___init__(self):
doc = ("Invoked after changing the tip of a branch object. Called with"
@@ -154,7 +153,7 @@
callback_repr, repr(hook))
-class TestHookRegistry(TestCase):
+class TestHookRegistry(tests.TestCase):
def test_items_are_reasonable_keys(self):
# All the items in the known_hooks registry need to map from
@@ -170,6 +169,7 @@
new_hooks = factory()
self.assertIsInstance(obj, Hooks)
self.assertEqual(type(obj), type(new_hooks))
+ self.assertEqual("No hook name", new_hooks.get_hook_name(None))
def test_known_hooks_key_to_object(self):
self.assertIs(branch.Branch.hooks,
=== modified file 'bzrlib/version_info_formats/format_rio.py'
--- a/bzrlib/version_info_formats/format_rio.py 2009-04-06 02:54:48 +0000
+++ b/bzrlib/version_info_formats/format_rio.py 2009-11-03 09:32:17 +0000
@@ -84,6 +84,7 @@
"""Hooks for rio-formatted version-info output."""
def __init__(self):
+ super(RioVersionInfoBuilderHooks, self).__init__()
self.create_hook(hooks.HookPoint('revision',
"Invoked when adding information about a revision to the"
" RIO stanza that is printed. revision is called with a"
More information about the bazaar-commits
mailing list