~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/branch_implementations/test_hooks.py

remove all trailing whitespace from bzr source

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
    def capture_set_rh_hook(self, branch, rev_history):
33
33
        """Capture post set-rh hook calls to self.hook_calls.
34
 
        
 
34
 
35
35
        The call is logged, as is some state of the branch.
36
36
        """
37
37
        self.hook_calls.append(
87
87
 
88
88
    def install_logging_hook(self, prefix):
89
89
        """Add a hook that logs calls made to it.
90
 
        
 
90
 
91
91
        :returns: the list that the calls will be appended to.
92
92
        """
93
93
        hook_calls = []
142
142
 
143
143
class TestPreChangeBranchTip(ChangeBranchTipTestCase):
144
144
    """Tests for pre_change_branch_tip hook.
145
 
    
 
145
 
146
146
    Most of these tests are very similar to the tests in
147
147
    TestPostChangeBranchTip.
148
148
    """
160
160
 
161
161
    def test_hook_failure_prevents_change(self):
162
162
        """If a hook raises an exception, the change does not take effect.
163
 
        
 
163
 
164
164
        Also, a HookFailed exception will be raised.
165
165
        """
166
166
        branch = self.make_branch_with_revision_ids(
176
176
        self.assertIsInstance(hook_failed_exc.exc_value, PearShapedError)
177
177
        # The revision info is unchanged.
178
178
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
179
 
        
 
179
 
180
180
    def test_empty_history(self):
181
181
        branch = self.make_branch('source')
182
182
        hook_calls = self.install_logging_hook('pre')
220
220
 
221
221
    def test_explicit_reject_by_hook(self):
222
222
        """If a hook raises TipChangeRejected, the change does not take effect.
223
 
        
 
223
 
224
224
        TipChangeRejected exceptions are propagated, not wrapped in HookFailed.
225
225
        """
226
226
        branch = self.make_branch_with_revision_ids(
233
233
            TipChangeRejected, branch.set_last_revision_info, 0, NULL_REVISION)
234
234
        # The revision info is unchanged.
235
235
        self.assertEqual((2, 'two-\xc2\xb5'), branch.last_revision_info())
236
 
        
 
236
 
237
237
 
238
238
class TestPostChangeBranchTip(ChangeBranchTipTestCase):
239
239
    """Tests for post_change_branch_tip hook.
304
304
    def setUp(self):
305
305
        ChangeBranchTipTestCase.setUp(self)
306
306
        self.installPreAndPostHooks()
307
 
        
 
307
 
308
308
    def installPreAndPostHooks(self):
309
309
        self.pre_hook_calls = self.install_logging_hook('pre')
310
310
        self.post_hook_calls = self.install_logging_hook('post')
347
347
        source_branch.push(destination_branch)
348
348
        self.assertPreAndPostHooksWereInvoked()
349
349
 
350
 
        
 
350