Fix wrong code duplication in utils.itersubclasses()
Change-Id: Ic34be7cb10b5aba723394e06ddff69cb09fe698d Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
parent
803be8cc8f
commit
f50e44dc89
@ -105,7 +105,6 @@ def itersubclasses(cls, _seen=None):
|
||||
subs = cls.__subclasses__()
|
||||
except TypeError: # fails only when cls is type
|
||||
subs = cls.__subclasses__(cls)
|
||||
subs = cls.__subclasses__()
|
||||
for sub in subs:
|
||||
if sub not in _seen:
|
||||
_seen.add(sub)
|
||||
|
@ -92,3 +92,8 @@ class UtilsTestCase(test.TestCase):
|
||||
pass
|
||||
|
||||
self.assertEqual([B, C, D], list(utils.itersubclasses(A)))
|
||||
|
||||
class E(type):
|
||||
pass
|
||||
|
||||
self.assertEqual([], list(utils.itersubclasses(E)))
|
||||
|
Loading…
Reference in New Issue
Block a user