]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Now that TestCase is a new-style class, change loadTestsFromModule and
authorGuido van Rossum <guido@python.org>
Mon, 30 Sep 2002 19:25:56 +0000 (19:25 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 30 Sep 2002 19:25:56 +0000 (19:25 +0000)
loadTestsFromName to accept new-style classes too!

Lib/unittest.py

index 64d54d8b7df26a03897d8cb87b0f8dc6ff40af1d..9100a78dbbf98d1bb28c1a2e9e8ad476d9bc3693 100644 (file)
@@ -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__)