~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_hooks.py

Rework test_script a little bit.


Don't allow someone to request a stdin request to echo.
Echo never reads from stdin, it just echos its arguments.
You use 'cat' if you want to read from stdin.

A few other fixes because the tests were using filenames
that are actually illegal on Windows, rather than just
nonexistant.


Change the exception handling for commands so that
unknown errors don't get silently squashed and then
turn into hard-to-debug errors later.

test_script now passes on Windows.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for the core Hooks logic."""
18
18
 
19
 
from bzrlib import branch, errors
 
19
from bzrlib import (
 
20
    branch,
 
21
    errors,
 
22
    tests,
 
23
    )
20
24
from bzrlib.hooks import (
21
25
    HookPoint,
22
26
    Hooks,
24
28
    known_hooks_key_to_object,
25
29
    known_hooks_key_to_parent_and_attribute,
26
30
    )
27
 
from bzrlib.errors import (
28
 
    UnknownHook,
29
 
    )
30
 
 
31
 
from bzrlib.tests import TestCase
32
 
 
33
 
 
34
 
class TestHooks(TestCase):
 
31
 
 
32
 
 
33
class TestHooks(tests.TestCase):
35
34
 
36
35
    def test_create_hook_first(self):
37
36
        hooks = Hooks()
95
94
 
96
95
    def test_install_named_hook_raises_unknown_hook(self):
97
96
        hooks = Hooks()
98
 
        self.assertRaises(UnknownHook, hooks.install_named_hook, 'silly',
 
97
        self.assertRaises(errors.UnknownHook, hooks.install_named_hook, 'silly',
99
98
                          None, "")
100
99
 
101
100
    def test_install_named_hook_appends_known_hook(self):
111
110
        self.assertEqual("demo", hooks.get_hook_name(None))
112
111
 
113
112
 
114
 
class TestHook(TestCase):
 
113
class TestHook(tests.TestCase):
115
114
 
116
115
    def test___init__(self):
117
116
        doc = ("Invoked after changing the tip of a branch object. Called with"
154
153
            callback_repr, repr(hook))
155
154
 
156
155
 
157
 
class TestHookRegistry(TestCase):
 
156
class TestHookRegistry(tests.TestCase):
158
157
 
159
158
    def test_items_are_reasonable_keys(self):
160
159
        # All the items in the known_hooks registry need to map from
170
169
            new_hooks = factory()
171
170
            self.assertIsInstance(obj, Hooks)
172
171
            self.assertEqual(type(obj), type(new_hooks))
 
172
            self.assertEqual("No hook name", new_hooks.get_hook_name(None))
173
173
 
174
174
    def test_known_hooks_key_to_object(self):
175
175
        self.assertIs(branch.Branch.hooks,