]> granicus.if.org Git - python/commitdiff
Patch #1061904 / bug #878275: give a nicer error message when someone
authorJohannes Gijsbers <jlg@dds.nl>
Sun, 7 Nov 2004 15:46:25 +0000 (15:46 +0000)
committerJohannes Gijsbers <jlg@dds.nl>
Sun, 7 Nov 2004 15:46:25 +0000 (15:46 +0000)
accidentally derives from TestSuite instead of TestCase.

Lib/unittest.py

index 3375067c8d07643090987db092f10b8e1a9a1931..70645fbce5db8a2c39d7b2200b612163601acadf 100644 (file)
@@ -489,6 +489,8 @@ class TestLoader:
 
     def loadTestsFromTestCase(self, testCaseClass):
         """Return a suite of all tests cases contained in testCaseClass"""
+        if issubclass(testCaseClass, TestSuite):
+            raise TypeError("Test cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?")
         testCaseNames = self.getTestCaseNames(testCaseClass)
         if not testCaseNames and hasattr(testCaseClass, 'runTest'):
             testCaseNames = ['runTest']