diff options
author | Walter Dörwald <walter@livinglogic.de> | 2002-12-12 19:14:08 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2002-12-12 19:14:08 (GMT) |
commit | 7e5c6a02eba1a6f5e93bfa1241ceff39bec9f3c9 (patch) | |
tree | 503cd8986a6ced722156e1e4eda5accd6e8bc9e8 /Lib | |
parent | 1b3b49d1325475bc54743125ee5e519c62fc45f1 (diff) | |
download | cpython-7e5c6a02eba1a6f5e93bfa1241ceff39bec9f3c9.zip cpython-7e5c6a02eba1a6f5e93bfa1241ceff39bec9f3c9.tar.gz cpython-7e5c6a02eba1a6f5e93bfa1241ceff39bec9f3c9.tar.bz2 |
Change issubclass() so that recursive tuples (directly or indirectly
containing class objects) are allowed as the second argument.
This makes issubclass() more similar to isinstance() where recursive
tuples are allowed too.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_isinstance.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py index 1bb09a6..5a19387 100644 --- a/Lib/test/test_isinstance.py +++ b/Lib/test/test_isinstance.py @@ -165,6 +165,13 @@ class Super: class Child(Super): pass +# new-style classes +class NewSuper(object): + pass + +class NewChild(NewSuper): + pass + class TestIsInstanceIsSubclass(unittest.TestCase): @@ -225,7 +232,17 @@ class TestIsInstanceIsSubclass(unittest.TestCase): self.assertEqual(False, issubclass(Super, (Child,))) self.assertEqual(True, issubclass(Super, (Child, Super))) self.assertEqual(False, issubclass(Child, ())) - self.assertRaises(TypeError, issubclass, Child, ((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, (long, (float, int)))) + self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring)))) |