From: Guido van Rossum Date: Mon, 30 Sep 2002 19:25:56 +0000 (+0000) Subject: Now that TestCase is a new-style class, change loadTestsFromModule and X-Git-Tag: v2.3c1~3935 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=679113702c54dd9fe5615e1b51af0b50416711b6;p=thirdparty%2FPython%2Fcpython.git Now that TestCase is a new-style class, change loadTestsFromModule and loadTestsFromName to accept new-style classes too! --- diff --git a/Lib/unittest.py b/Lib/unittest.py index 64d54d8b7df2..9100a78dbbf9 100644 --- a/Lib/unittest.py +++ b/Lib/unittest.py @@ -422,7 +422,8 @@ class TestLoader: tests = [] for name in dir(module): obj = getattr(module, name) - if type(obj) == types.ClassType and issubclass(obj, TestCase): + if (isinstance(obj, (type, types.ClassType)) and + issubclass(obj, TestCase)): tests.append(self.loadTestsFromTestCase(obj)) return self.suiteClass(tests) @@ -456,7 +457,8 @@ class TestLoader: import unittest if type(obj) == types.ModuleType: return self.loadTestsFromModule(obj) - elif type(obj) == types.ClassType and issubclass(obj, unittest.TestCase): + elif (isinstance(obj, (type, types.ClassType)) and + issubclass(obj, unittest.TestCase)): return self.loadTestsFromTestCase(obj) elif type(obj) == types.UnboundMethodType: return obj.im_class(obj.__name__)