summaryrefslogtreecommitdiff
path: root/Lib/unittest.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 0d69f52687..483f00670b 100644
--- a/Lib/unittest.py
+++ b/Lib/unittest.py
@@ -428,9 +428,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)