Topical change: use 'startswith()' to identify test methods with a

given prefix rather than comparing a slice.
This commit is contained in:
Steve Purcell 2003-09-23 08:41:53 +00:00
parent 09fad27a29
commit 3198275ace
1 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
__author__ = "Steve Purcell" __author__ = "Steve Purcell"
__email__ = "stephen_purcell at yahoo dot com" __email__ = "stephen_purcell at yahoo dot com"
__version__ = "#Revision: 1.56 $"[11:-2] __version__ = "#Revision: 1.57 $"[11:-2]
import time import time
import sys import sys
@ -540,7 +540,7 @@ class TestLoader:
"""Return a sorted sequence of method names found within testCaseClass """Return a sorted sequence of method names found within testCaseClass
""" """
def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix): def isTestMethod(attrname, testCaseClass=testCaseClass, prefix=self.testMethodPrefix):
return attrname[:len(prefix)] == prefix and callable(getattr(testCaseClass, attrname)) return attrname.startswith(prefix) and callable(getattr(testCaseClass, attrname))
testFnNames = filter(isTestMethod, dir(testCaseClass)) testFnNames = filter(isTestMethod, dir(testCaseClass))
for baseclass in testCaseClass.__bases__: for baseclass in testCaseClass.__bases__:
for testFnName in self.getTestCaseNames(baseclass): for testFnName in self.getTestCaseNames(baseclass):