From: Johannes Gijsbers Date: Sun, 7 Nov 2004 15:46:25 +0000 (+0000) Subject: Patch #1061904 / bug #878275: give a nicer error message when someone X-Git-Tag: v2.4c1~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7b6ad4b600fb8c89683d6efa6b350d5d47a5700;p=python Patch #1061904 / bug #878275: give a nicer error message when someone accidentally derives from TestSuite instead of TestCase. --- diff --git a/Lib/unittest.py b/Lib/unittest.py index 3375067c8d..70645fbce5 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -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']