From: Steve Purcell Date: Tue, 23 Sep 2003 08:41:53 +0000 (+0000) Subject: Topical change: use 'startswith()' to identify test methods with a X-Git-Tag: v2.4a1~1531 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3198275acef08b4fc7ea8939ed91105f50148e1e;p=python Topical change: use 'startswith()' to identify test methods with a given prefix rather than comparing a slice. --- diff --git a/Lib/unittest.py b/Lib/unittest.py index f44769e926..56c6da5d3c 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -46,7 +46,7 @@ SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. __author__ = "Steve Purcell" __email__ = "stephen_purcell at yahoo dot com" -__version__ = "#Revision: 1.56 $"[11:-2] +__version__ = "#Revision: 1.57 $"[11:-2] import time import sys @@ -540,7 +540,7 @@ class TestLoader: """Return a sorted sequence of method names found within testCaseClass """ 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)) for baseclass in testCaseClass.__bases__: for testFnName in self.getTestCaseNames(baseclass):