def test_class__single_subclass(self): class_, subclass = self._create_inheritance_chain(2) self.assertItemsEqual([subclass], __unit__.iter_subclasses(class_))
def test_class__no_subclasses(self): class_ = head(self._create_inheritance_chain(1)) self.assertEmpty(__unit__.iter_subclasses(class_))
def test_some_object(self): with self.assertRaises(TypeError): __unit__.iter_subclasses(object())
def test_none(self): with self.assertRaises(TypeError): __unit__.iter_subclasses(None)
def test_class__deep_hierarchy(self): tree = self._create_binary_inheritance_tree(4) class_, subclasses = tree[0], tree[1:] self.assertItemsEqual(subclasses, __unit__.iter_subclasses(class_))
def test_class__flat_hierarchy(self): class_ = self._create_class("Foo") subclasses = [self._create_class("Subclass%s" % i, bases=class_) for i in range(5)] self.assertItemsEqual(subclasses, __unit__.iter_subclasses(class_))