~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Move branch implementations tests into a package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
                      ]
66
66
def packages_to_test():
67
67
    import bzrlib.tests.blackbox
 
68
    import bzrlib.tests.branch_implementations
68
69
    return [
69
 
            bzrlib.tests.blackbox
 
70
            bzrlib.tests.blackbox,
 
71
            bzrlib.tests.branch_implementations,
70
72
            ]
71
73
 
72
74
 
812
814
                   'bzrlib.tests.test_workingtree',
813
815
                   'bzrlib.tests.test_xml',
814
816
                   ]
815
 
    test_branch_implementations = [
816
 
        'bzrlib.tests.test_branch_implementations']
817
817
    test_transport_implementations = [
818
818
        'bzrlib.tests.test_transport_implementations']
819
819
 
830
830
    loader = TestLoader()
831
831
    from bzrlib.transport import TransportTestProviderAdapter
832
832
    adapter = TransportTestProviderAdapter()
833
 
    for mod_name in test_transport_implementations:
834
 
        mod = _load_module_by_name(mod_name)
835
 
        for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
836
 
            suite.addTests(adapter.adapt(test))
837
 
    from bzrlib.branch import BranchTestProviderAdapter
838
 
    adapter = BranchTestProviderAdapter(
839
 
        bzrlib.transport.local.LocalRelpathServer,
840
 
        # None here will cause a readonly decorator to be created
841
 
        # by the TestCaseWithTransport.get_readonly_transport method.
842
 
        None,
843
 
        bzrlib.branch.BzrBranchFormat._formats.values())
844
 
    for mod_name in test_branch_implementations:
845
 
        mod = _load_module_by_name(mod_name)
846
 
        for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
847
 
            suite.addTests(adapter.adapt(test))
 
833
    adapt_modules(test_transport_implementations, adapter, loader, suite)
848
834
    for mod_name in testmod_names:
849
835
        mod = _load_module_by_name(mod_name)
850
836
        suite.addTest(loader.loadTestsFromModule(mod))
860
846
    return suite
861
847
 
862
848
 
 
849
def adapt_modules(mods_list, adapter, loader, suite):
 
850
    """Adapt the modules in mods_list using adapter and add to suite."""
 
851
    for mod_name in mods_list:
 
852
        mod = _load_module_by_name(mod_name)
 
853
        for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
 
854
            suite.addTests(adapter.adapt(test))
 
855
 
 
856
 
863
857
def _load_module_by_name(mod_name):
864
858
    parts = mod_name.split('.')
865
859
    module = __import__(mod_name)