Now that TestCase is a new-style class, change loadTestsFromModule and
loadTestsFromName to accept new-style classes too!
This commit is contained in:
parent
42d1d3edc0
commit
679113702c
|
@ -422,7 +422,8 @@ class TestLoader:
|
||||||
tests = []
|
tests = []
|
||||||
for name in dir(module):
|
for name in dir(module):
|
||||||
obj = getattr(module, name)
|
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))
|
tests.append(self.loadTestsFromTestCase(obj))
|
||||||
return self.suiteClass(tests)
|
return self.suiteClass(tests)
|
||||||
|
|
||||||
|
@ -456,7 +457,8 @@ class TestLoader:
|
||||||
import unittest
|
import unittest
|
||||||
if type(obj) == types.ModuleType:
|
if type(obj) == types.ModuleType:
|
||||||
return self.loadTestsFromModule(obj)
|
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)
|
return self.loadTestsFromTestCase(obj)
|
||||||
elif type(obj) == types.UnboundMethodType:
|
elif type(obj) == types.UnboundMethodType:
|
||||||
return obj.im_class(obj.__name__)
|
return obj.im_class(obj.__name__)
|
||||||
|
|
Loading…
Reference in New Issue