Commit d480b337 authored by Georg Brandl's avatar Georg Brandl

backport rev. 54207: add a few sanity checks in unittest.TestSuite.addTest(s).

parent 4a7da9cd
......@@ -411,9 +411,18 @@ class TestSuite:
return cases
def addTest(self, test):
# sanity checks
if not callable(test):
raise TypeError("the test to add must be callable")
if (isinstance(test, (type, types.ClassType)) and
issubclass(test, (TestCase, TestSuite))):
raise TypeError("TestCases and TestSuites must be instantiated "
"before passing them to addTest()")
self._tests.append(test)
def addTests(self, tests):
if isinstance(tests, basestring):
raise TypeError("tests must be an iterable of tests, not a string")
for test in tests:
self.addTest(test)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment