~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2009-07-24 03:15:56 UTC
  • mfrom: (4565 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4566.
  • Revision ID: mbp@sourcefrog.net-20090724031556-5zyef6f1ixtn6r3z
merge news

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
            def get_test_permutations(self):
121
121
                return sample_permutation
122
122
        sample_permutation = [(1,2), (3,4)]
123
 
        from bzrlib.tests.test_transport_implementations \
124
 
            import get_transport_test_permutations
 
123
        from bzrlib.tests.per_transport import get_transport_test_permutations
125
124
        self.assertEqual(sample_permutation,
126
125
                         get_transport_test_permutations(MockModule()))
127
126
 
130
129
        # as there are in all the registered transport modules - we assume if
131
130
        # this matches its probably doing the right thing especially in
132
131
        # combination with the tests for setting the right classes below.
133
 
        from bzrlib.tests.test_transport_implementations \
134
 
            import transport_test_permutations
 
132
        from bzrlib.tests.per_transport import transport_test_permutations
135
133
        from bzrlib.transport import _get_transport_modules
136
134
        modules = _get_transport_modules()
137
135
        permutation_count = 0
149
147
        # This test used to know about all the possible transports and the
150
148
        # order they were returned but that seems overly brittle (mbp
151
149
        # 20060307)
152
 
        from bzrlib.tests.test_transport_implementations \
153
 
            import transport_test_permutations
 
150
        from bzrlib.tests.per_transport import transport_test_permutations
154
151
        scenarios = transport_test_permutations()
155
152
        # there are at least that many builtin transports
156
153
        self.assertTrue(len(scenarios) > 6)
167
164
    def test_scenarios(self):
168
165
        # check that constructor parameters are passed through to the adapted
169
166
        # test.
170
 
        from bzrlib.tests.branch_implementations import make_scenarios
 
167
        from bzrlib.tests.per_branch import make_scenarios
171
168
        server1 = "a"
172
169
        server2 = "b"
173
170
        formats = [("c", "C"), ("d", "D")]
192
189
    def test_scenarios(self):
193
190
        # check that constructor parameters are passed through to the adapted
194
191
        # test.
195
 
        from bzrlib.tests.bzrdir_implementations import make_scenarios
 
192
        from bzrlib.tests.per_bzrdir import make_scenarios
196
193
        vfs_factory = "v"
197
194
        server1 = "a"
198
195
        server2 = "b"
293
290
    def test_scenarios(self):
294
291
        # check that constructor parameters are passed through to the adapted
295
292
        # test.
296
 
        from bzrlib.tests.interrepository_implementations import \
297
 
            make_scenarios
 
293
        from bzrlib.tests.per_interrepository import make_scenarios
298
294
        server1 = "a"
299
295
        server2 = "b"
300
296
        formats = [(str, "C1", "C2"), (int, "D1", "D2")]
320
316
    def test_scenarios(self):
321
317
        # check that constructor parameters are passed through to the adapted
322
318
        # test.
323
 
        from bzrlib.tests.workingtree_implementations \
324
 
            import make_scenarios
 
319
        from bzrlib.tests.per_workingtree import make_scenarios
325
320
        server1 = "a"
326
321
        server2 = "b"
327
322
        formats = [workingtree.WorkingTreeFormat2(),
351
346
        # workingtree_to_test_tree attribute set to 'return_parameter' and the
352
347
        # revision one set to revision_tree_from_workingtree.
353
348
 
354
 
        from bzrlib.tests.tree_implementations import (
 
349
        from bzrlib.tests.per_tree import (
355
350
            _dirstate_tree_from_workingtree,
356
351
            make_scenarios,
357
352
            preview_tree_pre,
433
428
        # unlike the TestProviderAdapter we dont want to automatically add a
434
429
        # parameterized one for WorkingTree - the optimisers will tell us what
435
430
        # ones to add.
436
 
        from bzrlib.tests.tree_implementations import (
 
431
        from bzrlib.tests.per_tree import (
437
432
            return_parameter,
438
433
            revision_tree_from_workingtree
439
434
            )
440
 
        from bzrlib.tests.intertree_implementations import (
 
435
        from bzrlib.tests.per_intertree import (
441
436
            make_scenarios,
442
437
            )
443
438
        from bzrlib.workingtree import WorkingTreeFormat2, WorkingTreeFormat3
728
723
                self.time(time.sleep, 0.003)
729
724
        self.check_timing(ShortDelayTestCase('test_short_delay'),
730
725
                          r"^ +[0-9]+ms$")
731
 
        # if a benchmark time is given, we want a x of y style result.
 
726
        # if a benchmark time is given, we now show just that time followed by
 
727
        # a star
732
728
        self.check_timing(ShortDelayTestCase('test_short_benchmark'),
733
 
                          r"^ +[0-9]+ms/ +[0-9]+ms$")
 
729
                          r"^ +[0-9]+ms\*$")
734
730
 
735
731
    def test_unittest_reporting_unittest_class(self):
736
732
        # getting the time from a non-bzrlib test works ok
948
944
        result.report_unsupported(test, feature)
949
945
        output = result_stream.getvalue()[prefix:]
950
946
        lines = output.splitlines()
951
 
        self.assertEqual(lines, ['NODEP                   0ms',
 
947
        self.assertEqual(lines, ['NODEP        0ms',
952
948
                                 "    The feature 'Feature' is not available."])
953
949
 
954
950
    def test_text_report_unsupported(self):
1495
1491
        sample_test.run(result)
1496
1492
        self.assertContainsRe(
1497
1493
            output_stream.getvalue(),
1498
 
            r"\d+ms/ +\d+ms\n$")
 
1494
            r"\d+ms\*\n$")
1499
1495
 
1500
1496
    def test_hooks_sanitised(self):
1501
1497
        """The bzrlib hooks should be sanitised by setUp."""
1691
1687
    def test_assert_isinstance(self):
1692
1688
        self.assertIsInstance(2, int)
1693
1689
        self.assertIsInstance(u'', basestring)
1694
 
        self.assertRaises(AssertionError, self.assertIsInstance, None, int)
 
1690
        e = self.assertRaises(AssertionError, self.assertIsInstance, None, int)
 
1691
        self.assertEquals(str(e),
 
1692
            "None is an instance of <type 'NoneType'> rather than <type 'int'>")
1695
1693
        self.assertRaises(AssertionError, self.assertIsInstance, 23.3, int)
 
1694
        e = self.assertRaises(AssertionError,
 
1695
            self.assertIsInstance, None, int, "it's just not")
 
1696
        self.assertEquals(str(e),
 
1697
            "None is an instance of <type 'NoneType'> rather than <type 'int'>"
 
1698
            ": it's just not")
1696
1699
 
1697
1700
    def test_assertEndsWith(self):
1698
1701
        self.assertEndsWith('foo', 'oo')
2203
2206
        test_list = [
2204
2207
            # testmod_names
2205
2208
            'bzrlib.tests.blackbox.test_branch.TestBranch.test_branch',
 
2209
            ('bzrlib.tests.per_transport.TransportTests'
 
2210
             '.test_abspath(LocalURLServer)'),
2206
2211
            'bzrlib.tests.test_selftest.TestTestSuite.test_test_suite',
2207
 
            # transport implementations
2208
 
            'bzrlib.tests.test_transport_implementations.TransportTests'
2209
 
            '.test_abspath(LocalURLServer)',
2210
2212
            # modules_to_doctest
2211
2213
            'bzrlib.timestamp.format_highres_date',
2212
2214
            # plugins can't be tested that way since selftest may be run with