32
31
def test_install_hook_raises_unknown_hook(self):
33
32
"""install_hook should raise UnknownHook if a hook is unknown."""
35
self.assertRaises(UnknownHook, self.applyDeprecated, one_five,
36
hooks.install_hook, 'silly', None)
34
self.assertRaises(UnknownHook, hooks.install_hook, 'silly', None)
38
36
def test_install_hook_appends_known_hook(self):
39
37
"""install_hook should append the callable for known hooks."""
41
39
hooks['set_rh'] = []
42
self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
43
self.assertEqual(hooks['set_rh'], [None])
45
def test_install_named_hook_raises_unknown_hook(self):
47
self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
50
def test_install_named_hook_appends_known_hook(self):
53
hooks.install_named_hook('set_rh', None, "demo")
54
self.assertEqual(hooks['set_rh'], [None])
56
def test_install_named_hook_and_retrieve_name(self):
59
hooks.install_named_hook('set_rh', None, "demo")
60
self.assertEqual("demo", hooks.get_hook_name(None))
40
hooks.install_hook('set_rh', None)
41
self.assertEqual(hooks['set_rh'], [None])
62
43
def test_name_hook_and_retrieve_name(self):
63
44
"""name_hook puts the name in the names mapping."""
65
46
hooks['set_rh'] = []
66
self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
47
hooks.install_hook('set_rh', None)
67
48
hooks.name_hook(None, 'demo')
68
49
self.assertEqual("demo", hooks.get_hook_name(None))
70
51
def test_get_unnamed_hook_name_is_unnamed(self):
72
53
hooks['set_rh'] = []
73
self.applyDeprecated(one_five, hooks.install_hook, 'set_rh', None)
54
hooks.install_hook('set_rh', None)
74
55
self.assertEqual("No hook name", hooks.get_hook_name(None))