~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-01 08:02:42 UTC
  • mfrom: (5390.3.3 faster-revert-593560)
  • Revision ID: pqm@pqm.ubuntu.com-20100901080242-esg62ody4frwmy66
(spiv) Avoid repeatedly calling self.target.all_file_ids() in
 InterTree.iter_changes. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
114
114
    TestUtil,
115
115
    treeshape,
116
116
    )
117
 
from bzrlib.tests.http_server import HttpServer
118
 
from bzrlib.tests.TestUtil import (
119
 
                          TestSuite,
120
 
                          TestLoader,
121
 
                          )
122
117
from bzrlib.ui import NullProgressView
123
118
from bzrlib.ui.text import TextUIFactory
124
119
import bzrlib.version_info_formats.format_custom
848
843
        # going away but leak one) but it seems less likely than the actual
849
844
        # false positives (the test see threads going away and does not leak).
850
845
        if leaked_threads > 0:
 
846
            if 'threads' in selftest_debug_flags:
 
847
                print '%s is leaking, active is now %d' % (self.id(), active)
851
848
            TestCase._leaking_threads_tests += 1
852
849
            if TestCase._first_thread_leaker_id is None:
853
850
                TestCase._first_thread_leaker_id = self.id()
2439
2436
 
2440
2437
    def setUp(self):
2441
2438
        super(TestCaseWithMemoryTransport, self).setUp()
 
2439
        # Ensure that ConnectedTransport doesn't leak sockets
 
2440
        def get_transport_with_cleanup(*args, **kwargs):
 
2441
            t = orig_get_transport(*args, **kwargs)
 
2442
            if isinstance(t, _mod_transport.ConnectedTransport):
 
2443
                self.addCleanup(t.disconnect)
 
2444
            return t
 
2445
 
 
2446
        orig_get_transport = self.overrideAttr(_mod_transport, 'get_transport',
 
2447
                                               get_transport_with_cleanup)
2442
2448
        self._make_test_root()
2443
2449
        self.addCleanup(os.chdir, os.getcwdu())
2444
2450
        self.makeAndChdirToTestDir()
2736
2742
    """
2737
2743
 
2738
2744
    def setUp(self):
 
2745
        from bzrlib.tests import http_server
2739
2746
        super(ChrootedTestCase, self).setUp()
2740
2747
        if not self.vfs_transport_factory == memory.MemoryServer:
2741
 
            self.transport_readonly_server = HttpServer
 
2748
            self.transport_readonly_server = http_server.HttpServer
2742
2749
 
2743
2750
 
2744
2751
def condition_id_re(pattern):
3065
3072
    return suite
3066
3073
 
3067
3074
 
3068
 
class TestDecorator(TestSuite):
 
3075
class TestDecorator(TestUtil.TestSuite):
3069
3076
    """A decorator for TestCase/TestSuite objects.
3070
3077
    
3071
3078
    Usually, subclasses should override __iter__(used when flattening test
3074
3081
    """
3075
3082
 
3076
3083
    def __init__(self, suite):
3077
 
        TestSuite.__init__(self)
 
3084
        TestUtil.TestSuite.__init__(self)
3078
3085
        self.addTest(suite)
3079
3086
 
3080
3087
    def countTestCases(self):
3248
3255
 
3249
3256
    test_blocks = partition_tests(suite, concurrency)
3250
3257
    for process_tests in test_blocks:
3251
 
        process_suite = TestSuite()
 
3258
        process_suite = TestUtil.TestSuite()
3252
3259
        process_suite.addTests(process_tests)
3253
3260
        c2pread, c2pwrite = os.pipe()
3254
3261
        pid = os.fork()
3409
3416
#                           rather than failing tests. And no longer raise
3410
3417
#                           LockContention when fctnl locks are not being used
3411
3418
#                           with proper exclusion rules.
 
3419
#   -Ethreads               Will display thread ident at creation/join time to
 
3420
#                           help track thread leaks
3412
3421
selftest_debug_flags = set()
3413
3422
 
3414
3423
 
3649
3658
        'bzrlib.tests.commands',
3650
3659
        'bzrlib.tests.doc_generate',
3651
3660
        'bzrlib.tests.per_branch',
3652
 
        'bzrlib.tests.per_bzrdir',
3653
 
        'bzrlib.tests.per_bzrdir_colo',
 
3661
        'bzrlib.tests.per_controldir',
 
3662
        'bzrlib.tests.per_controldir_colo',
3654
3663
        'bzrlib.tests.per_foreign_vcs',
3655
3664
        'bzrlib.tests.per_interrepository',
3656
3665
        'bzrlib.tests.per_intertree',
3808
3817
        'bzrlib.tests.test_switch',
3809
3818
        'bzrlib.tests.test_symbol_versioning',
3810
3819
        'bzrlib.tests.test_tag',
 
3820
        'bzrlib.tests.test_test_server',
3811
3821
        'bzrlib.tests.test_testament',
3812
3822
        'bzrlib.tests.test_textfile',
3813
3823
        'bzrlib.tests.test_textmerge',
4004
4014
    ...     bzrlib.tests.test_sampler.DemoTest('test_nothing'),
4005
4015
    ...     [('one', dict(param=1)),
4006
4016
    ...      ('two', dict(param=2))],
4007
 
    ...     TestSuite())
 
4017
    ...     TestUtil.TestSuite())
4008
4018
    >>> tests = list(iter_suite_tests(r))
4009
4019
    >>> len(tests)
4010
4020
    2