~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

Merge config-lock-remote into config-options

Show diffs side-by-side

added added

removed removed

Lines of Context:
3522
3522
        self.assertDocTestStringFails(doctest.DocTestSuite, test)
3523
3523
        # tests.DocTestSuite sees None
3524
3524
        self.assertDocTestStringSucceds(tests.IsolatedDocTestSuite, test)
 
3525
 
 
3526
 
 
3527
class TestSelftestExcludePatterns(tests.TestCase):
 
3528
 
 
3529
    def setUp(self):
 
3530
        super(TestSelftestExcludePatterns, self).setUp()
 
3531
        self.overrideAttr(tests, 'test_suite', self.suite_factory)
 
3532
 
 
3533
    def suite_factory(self, keep_only=None, starting_with=None):
 
3534
        """A test suite factory with only a few tests."""
 
3535
        class Test(tests.TestCase):
 
3536
            def id(self):
 
3537
                # We don't need the full class path
 
3538
                return self._testMethodName
 
3539
            def a(self):
 
3540
                pass
 
3541
            def b(self):
 
3542
                pass
 
3543
            def c(self):
 
3544
                pass
 
3545
        return TestUtil.TestSuite([Test("a"), Test("b"), Test("c")])
 
3546
 
 
3547
    def assertTestList(self, expected, *selftest_args):
 
3548
        # We rely on setUp installing the right test suite factory so we can
 
3549
        # test at the command level without loading the whole test suite
 
3550
        out, err = self.run_bzr(('selftest', '--list') + selftest_args)
 
3551
        actual = out.splitlines()
 
3552
        self.assertEquals(expected, actual)
 
3553
 
 
3554
    def test_full_list(self):
 
3555
        self.assertTestList(['a', 'b', 'c'])
 
3556
 
 
3557
    def test_single_exclude(self):
 
3558
        self.assertTestList(['b', 'c'], '-x', 'a')
 
3559
 
 
3560
    def test_mutiple_excludes(self):
 
3561
        self.assertTestList(['c'], '-x', 'a', '-x', 'b')