Closes #13258: Use callable() built-in in the standard library.
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index afdff67..cb92fd2 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -113,7 +113,7 @@
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 @@
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: