~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-24 19:21:32 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100824192132-2ktt5adkbk5bk1ct
Handle test_source and extensions. Also define an 'extern' protocol, to allow
the test suite to recognize that returning an object of that type is a Python object.

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