~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

Implement BranchTestProviderAdapter, so tests now run across all branch formats.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
import bzrlib.store
47
47
import bzrlib.trace
48
48
from bzrlib.transport import urlescape
 
49
import bzrlib.transport
49
50
from bzrlib.trace import mutter
50
51
from bzrlib.tests.TestUtil import TestLoader, TestSuite
51
52
from bzrlib.tests.treeshape import build_tree_contents
74
75
        self._result = result
75
76
 
76
77
    def addError(self, test, err):
 
78
        if (isinstance(err[1], TestSkipped) and 
 
79
            getattr(self, "addSkipped", None) is not None):
 
80
            return self.addSkipped(test, err)    
77
81
        self._result.addError(test, err)
78
82
        self._result.stop()
79
83
 
166
170
        for test, err in errors:
167
171
            self.stream.writeln(self.separator1)
168
172
            self.stream.writeln("%s: %s" % (flavour, self.getDescription(test)))
169
 
            if hasattr(test, '_get_log'):
 
173
            if getattr(test, '_get_log', None) is not None:
170
174
                print >>self.stream
171
175
                print >>self.stream, \
172
176
                        ('vvvv[log from %s]' % test.id()).ljust(78,'-')
487
491
        if stdin is None:
488
492
            stdin = StringIO("")
489
493
        if stdout is None:
490
 
            if hasattr(self, "_log_file"):
 
494
            if getattr(self, "_log_file", None) is not None:
491
495
                stdout = self._log_file
492
496
            else:
493
497
                stdout = StringIO()
494
498
        if stderr is None:
495
 
            if hasattr(self, "_log_file"):
 
499
            if getattr(self, "_log_file", None is not None):
496
500
                stderr = self._log_file
497
501
            else:
498
502
                stderr = StringIO()
731
735
                   'bzrlib.tests.test_workingtree',
732
736
                   'bzrlib.tests.test_xml',
733
737
                   ]
 
738
    test_branch_implementations = [
 
739
        'bzrlib.tests.test_branch_implementations']
734
740
    test_transport_implementations = [
735
741
        'bzrlib.tests.test_transport_implementations']
736
742
 
751
757
        mod = _load_module_by_name(mod_name)
752
758
        for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
753
759
            suite.addTests(adapter.adapt(test))
 
760
    from bzrlib.branch import BranchTestProviderAdapter
 
761
    adapter = BranchTestProviderAdapter(
 
762
        bzrlib.transport.local.LocalRelpathServer,
 
763
        bzrlib.transport.local.LocalRelpathServer,
 
764
        bzrlib.branch.BzrBranchFormat._formats.values())
 
765
    for mod_name in test_branch_implementations:
 
766
        mod = _load_module_by_name(mod_name)
 
767
        for test in iter_suite_tests(loader.loadTestsFromModule(mod)):
 
768
            suite.addTests(adapter.adapt(test))
754
769
    for mod_name in testmod_names:
755
770
        mod = _load_module_by_name(mod_name)
756
771
        suite.addTest(loader.loadTestsFromModule(mod))
761
776
    for m in (MODULES_TO_DOCTEST):
762
777
        suite.addTest(DocTestSuite(m))
763
778
    for name, plugin in bzrlib.plugin.all_plugins().items():
764
 
        if hasattr(plugin, 'test_suite'):
 
779
        if getattr(plugin, 'test_suite', None) is not None:
765
780
            suite.addTest(plugin.test_suite())
766
781
    return suite
767
782