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:
Zhi Yan Liu 2014-07-20 11:51:29 +08:00
parent 803be8cc8f
commit f50e44dc89
2 changed files with 5 additions and 1 deletions

View File

@ -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)

View File

@ -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)))