~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Jonathan Riddell
  • Date: 2011-06-17 09:07:12 UTC
  • mfrom: (5984 +trunk)
  • mto: (5971.2.3 bzr-gpgme)
  • mto: This revision was merged to the branch mainline in revision 6003.
  • Revision ID: jriddell@canonical.com-20110617090712-gbp520g89lwfhihn
mergeĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    branchbuilder,
44
44
    bzrdir,
45
45
    errors,
 
46
    hooks,
46
47
    lockdir,
47
48
    memorytree,
48
49
    osutils,
3559
3560
 
3560
3561
    def test_mutiple_excludes(self):
3561
3562
        self.assertTestList(['c'], '-x', 'a', '-x', 'b')
 
3563
 
 
3564
 
 
3565
class TestCounterHooks(tests.TestCase, SelfTestHelper):
 
3566
 
 
3567
    _test_needs_features = [features.subunit]
 
3568
 
 
3569
    def setUp(self):
 
3570
        super(TestCounterHooks, self).setUp()
 
3571
        class Test(tests.TestCase):
 
3572
 
 
3573
            def setUp(self):
 
3574
                super(Test, self).setUp()
 
3575
                self.hooks = hooks.Hooks()
 
3576
                self.hooks.add_hook('myhook', 'Foo bar blah', (2,4))
 
3577
                self.install_counter_hook(self.hooks, 'myhook')
 
3578
 
 
3579
            def no_hook(self):
 
3580
                pass
 
3581
 
 
3582
            def run_hook_once(self):
 
3583
                for hook in self.hooks['myhook']:
 
3584
                    hook(self)
 
3585
 
 
3586
        self.test_class = Test
 
3587
 
 
3588
    def assertHookCalls(self, expected_calls, test_name):
 
3589
        test = self.test_class(test_name)
 
3590
        result = unittest.TestResult()
 
3591
        test.run(result)
 
3592
        self.assertTrue(hasattr(test, '_counters'))
 
3593
        self.assertTrue(test._counters.has_key('myhook'))
 
3594
        self.assertEquals(expected_calls, test._counters['myhook'])
 
3595
 
 
3596
    def test_no_hook(self):
 
3597
        self.assertHookCalls(0, 'no_hook')
 
3598
 
 
3599
    def test_run_hook_once(self):
 
3600
        tt = features.testtools
 
3601
        if tt.module.__version__ < (0, 9, 8):
 
3602
            raise tests.TestSkipped('testtools-0.9.8 required for addDetail')
 
3603
        self.assertHookCalls(1, 'run_hook_once')