~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

Merge bzr.dev 4157, this breaks a couple per-repository tests.

Looks like removing some of the InterRepo optimizers is revealing places
that we haven't fully finished the RemoteRepo api.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1150
1150
        class SkippedTest(TestCase):
1151
1151
 
1152
1152
            def setUp(self):
 
1153
                TestCase.setUp(self)
1153
1154
                calls.append('setUp')
1154
1155
                self.addCleanup(self.cleanup)
1155
1156
 
1352
1353
class TestTestCase(TestCase):
1353
1354
    """Tests that test the core bzrlib TestCase."""
1354
1355
 
 
1356
    def test_assertLength_matches_empty(self):
 
1357
        a_list = []
 
1358
        self.assertLength(0, a_list)
 
1359
 
 
1360
    def test_assertLength_matches_nonempty(self):
 
1361
        a_list = [1, 2, 3]
 
1362
        self.assertLength(3, a_list)
 
1363
 
 
1364
    def test_assertLength_fails_different(self):
 
1365
        a_list = []
 
1366
        self.assertRaises(AssertionError, self.assertLength, 1, a_list)
 
1367
 
 
1368
    def test_assertLength_shows_sequence_in_failure(self):
 
1369
        a_list = [1, 2, 3]
 
1370
        exception = self.assertRaises(AssertionError, self.assertLength, 2,
 
1371
            a_list)
 
1372
        self.assertEqual('Incorrect length: wanted 2, got 3 for [1, 2, 3]',
 
1373
            exception.args[0])
 
1374
 
 
1375
    def test_base_setUp_not_called_causes_failure(self):
 
1376
        class TestCaseWithBrokenSetUp(TestCase):
 
1377
            def setUp(self):
 
1378
                pass # does not call TestCase.setUp
 
1379
            def test_foo(self):
 
1380
                pass
 
1381
        test = TestCaseWithBrokenSetUp('test_foo')
 
1382
        result = unittest.TestResult()
 
1383
        test.run(result)
 
1384
        self.assertFalse(result.wasSuccessful())
 
1385
        self.assertEqual(1, result.testsRun)
 
1386
 
 
1387
    def test_base_tearDown_not_called_causes_failure(self):
 
1388
        class TestCaseWithBrokenTearDown(TestCase):
 
1389
            def tearDown(self):
 
1390
                pass # does not call TestCase.tearDown
 
1391
            def test_foo(self):
 
1392
                pass
 
1393
        test = TestCaseWithBrokenTearDown('test_foo')
 
1394
        result = unittest.TestResult()
 
1395
        test.run(result)
 
1396
        self.assertFalse(result.wasSuccessful())
 
1397
        self.assertEqual(1, result.testsRun)
 
1398
 
1355
1399
    def test_debug_flags_sanitised(self):
1356
1400
        """The bzrlib debug flags should be sanitised by setUp."""
1357
1401
        if 'allow_debug' in tests.selftest_debug_flags:
1823
1867
class TestSelftestFiltering(TestCase):
1824
1868
 
1825
1869
    def setUp(self):
 
1870
        TestCase.setUp(self)
1826
1871
        self.suite = TestUtil.TestSuite()
1827
1872
        self.loader = TestUtil.TestLoader()
1828
1873
        self.suite.addTest(self.loader.loadTestsFromModuleNames([