~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/TestUtil.py

  • Committer: Vincent Ladeuil
  • Date: 2007-12-29 12:01:25 UTC
  • mto: (3169.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 3170.
  • Revision ID: v.ladeuil+lp@free.fr-20071229120125-1vf2l1w7x8y3pw9i
Reduce selftest overhead to establish test names by memoization.

* TestUtil.py:
(TestLoader.getTestCaseNames): Memoize test names.

Show diffs side-by-side

added added

removed removed

Lines of Context:
73
73
        visitTests(self, visitor)
74
74
 
75
75
 
 
76
# Memoize test names
 
77
test_func_names = {}
 
78
 
 
79
 
76
80
class TestLoader(unittest.TestLoader):
77
81
    """Custom TestLoader to extend the stock python one."""
78
82
 
122
126
        else:
123
127
            return basic_tests
124
128
 
 
129
    def getTestCaseNames(self, testCaseClass):
 
130
        testFnNames = test_func_names.get(testCaseClass, None)
 
131
        if testFnNames is not None:
 
132
            # We already calculate that
 
133
            return testFnNames
 
134
 
 
135
        testFnNames = unittest.TestLoader.getTestCaseNames(self, testCaseClass)
 
136
        test_func_names[testCaseClass] = testFnNames
 
137
        return testFnNames
125
138
 
126
139
def _load_module_by_name(mod_name):
127
140
    parts = mod_name.split('.')