/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

Add a new method ``Tree.revision_tree`` which allows access to cached
trees for arbitrary revisions. This allows the in development dirstate
tree format to provide access to the callers to cached copies of 
inventory data which are cheaper to access than inventories from the
repository. (Robert Collins, Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
 
71
71
class TestLoader(unittest.TestLoader):
72
 
    """Custome TestLoader to set the right TestSuite class."""
 
72
    """Custom  TestLoader to address some quirks in the stock python one."""
73
73
    suiteClass = TestSuite
74
74
 
 
75
    def loadTestsFromModuleNames(self, names):
 
76
        """use a custom means to load tests from modules.
 
77
 
 
78
        There is an undesirable glitch in the python TestLoader where a 
 
79
        import error is ignore. We think this can be solved by ensuring the 
 
80
        requested name is resolvable, if its not raising the original error.
 
81
        """
 
82
        result = self.suiteClass()
 
83
        for name in names:
 
84
            _load_module_by_name(name)
 
85
            result.addTests(self.loadTestsFromName(name))
 
86
        return result
 
87
 
 
88
 
 
89
def _load_module_by_name(mod_name):
 
90
    parts = mod_name.split('.')
 
91
    module = __import__(mod_name)
 
92
    del parts[0]
 
93
    # for historical reasons python returns the top-level module even though
 
94
    # it loads the submodule; we need to walk down to get the one we want.
 
95
    while parts:
 
96
        module = getattr(module, parts.pop(0))
 
97
    return module
 
98
 
 
99
 
75
100
class TestVisitor(object):
76
101
    """A visitor for Tests"""
77
102
    def visitSuite(self, aTestSuite):