~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

  • Committer: Vincent Ladeuil
  • Date: 2008-01-07 16:47:46 UTC
  • mfrom: (3146.7.2 selftest)
  • mto: This revision was merged to the branch mainline in revision 3170.
  • Revision ID: v.ladeuil+lp@free.fr-20080107164746-bome6yaxlwqbc7kh
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('.')