class Child(Super):
pass
-
-# new-style classes
-class NewSuper(object):
- pass
-
-class NewChild(NewSuper):
- pass
-
-
\f
class TestIsInstanceIsSubclass(unittest.TestCase):
# Tests to ensure that isinstance and issubclass work on abstract
self.assertEqual(False, issubclass(Child, ()))
self.assertEqual(True, issubclass(Super, (Child, (Super,))))
- self.assertEqual(True, issubclass(NewChild, (NewChild,)))
- self.assertEqual(True, issubclass(NewChild, (NewSuper,)))
- self.assertEqual(False, issubclass(NewSuper, (NewChild,)))
- self.assertEqual(True, issubclass(NewSuper, (NewChild, NewSuper)))
- self.assertEqual(False, issubclass(NewChild, ()))
- self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
-
self.assertEqual(True, issubclass(int, (int, (float, int))))
- self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
+ self.assertEqual(True, issubclass(str, (str, (Child, str))))
def test_subclass_recursion_limit(self):
# make sure that issubclass raises RecursionError before the C stack is