~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-01-07 17:49:38 UTC
  • mfrom: (3169.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20080107174938-hvwo399dzshh3cod
Reduce selftest overhead to establish test names by memoization

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
    """Custom TestLoader to extend the stock python one."""
78
78
 
79
79
    suiteClass = TestSuite
 
80
    # Memoize test names by test class dict
 
81
    test_func_names = {}
80
82
 
81
83
    def loadTestsFromModuleNames(self, names):
82
84
        """use a custom means to load tests from modules.
122
124
        else:
123
125
            return basic_tests
124
126
 
 
127
    def getTestCaseNames(self, test_case_class):
 
128
        test_fn_names = self.test_func_names.get(test_case_class, None)
 
129
        if test_fn_names is not None:
 
130
            # We already calculate that
 
131
            return test_fn_names
 
132
 
 
133
        test_fn_names = unittest.TestLoader.getTestCaseNames(self,
 
134
                                                             test_case_class)
 
135
        self.test_func_names[test_case_class] = test_fn_names
 
136
        return test_fn_names
125
137
 
126
138
def _load_module_by_name(mod_name):
127
139
    parts = mod_name.split('.')