summaryrefslogtreecommitdiffstats
path: root/Lib/unittest.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-09-30 19:25:56 (GMT)
committerGuido van Rossum <guido@python.org>2002-09-30 19:25:56 (GMT)
commit679113702c54dd9fe5615e1b51af0b50416711b6 (patch)
tree1f7a5106aa38952347ee15c00ddc8ec2eaa5180e /Lib/unittest.py
parent42d1d3edc01860e7713af6807ac7410cebbdb0a9 (diff)
downloadcpython-679113702c54dd9fe5615e1b51af0b50416711b6.zip
cpython-679113702c54dd9fe5615e1b51af0b50416711b6.tar.gz
cpython-679113702c54dd9fe5615e1b51af0b50416711b6.tar.bz2
Now that TestCase is a new-style class, change loadTestsFromModule and
loadTestsFromName to accept new-style classes too!
Diffstat (limited to 'Lib/unittest.py')
-rw-r--r--Lib/unittest.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/unittest.py b/Lib/unittest.py
index 64d54d8..9100a78 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__)