Merge 3.2

This commit is contained in:
Florent Xicluna 2011-10-28 14:52:29 +02:00
commit aabbda5354
27 changed files with 51 additions and 54 deletions

View file

@ -113,7 +113,7 @@ class TestLoader(object):
return self.suiteClass([inst])
elif isinstance(obj, suite.TestSuite):
return obj
if hasattr(obj, '__call__'):
if callable(obj):
test = obj()
if isinstance(test, suite.TestSuite):
return test
@ -138,7 +138,7 @@ class TestLoader(object):
def isTestMethod(attrname, testCaseClass=testCaseClass,
prefix=self.testMethodPrefix):
return attrname.startswith(prefix) and \
hasattr(getattr(testCaseClass, attrname), '__call__')
callable(getattr(testCaseClass, attrname))
testFnNames = testFnNames = list(filter(isTestMethod,
dir(testCaseClass)))
if self.sortTestMethodsUsing:

View file

@ -42,7 +42,7 @@ class BaseTestSuite(object):
def addTest(self, test):
# sanity checks
if not hasattr(test, '__call__'):
if not callable(test):
raise TypeError("{} is not callable".format(repr(test)))
if isinstance(test, type) and issubclass(test,
(case.TestCase, TestSuite)):