diff options
author | Benjamin Peterson <benjamin@python.org> | 2015-10-07 02:36:54 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2015-10-07 02:36:54 (GMT) |
commit | bd6c41a185ad4a2db9ad693a79496429e2f8d7ee (patch) | |
tree | f5a71ee3153ff4bd6f9c330530d36481cc0bd3d6 /Lib/test | |
parent | 106ddf07b3e120d79985bab8b6f8ee782c4c7184 (diff) | |
download | cpython-bd6c41a185ad4a2db9ad693a79496429e2f8d7ee.zip cpython-bd6c41a185ad4a2db9ad693a79496429e2f8d7ee.tar.gz cpython-bd6c41a185ad4a2db9ad693a79496429e2f8d7ee.tar.bz2 |
prevent unacceptable bases from becoming bases through multiple inheritance (#24806)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_descr.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py index 9a60a12..adce6e5 100644 --- a/Lib/test/test_descr.py +++ b/Lib/test/test_descr.py @@ -3735,6 +3735,37 @@ order (MRO) for bases """ else: assert 0, "best_base calculation found wanting" + def test_unsubclassable_types(self): + with self.assertRaises(TypeError): + class X(type(None)): + pass + with self.assertRaises(TypeError): + class X(object, type(None)): + pass + with self.assertRaises(TypeError): + class X(type(None), object): + pass + class O(object): + pass + with self.assertRaises(TypeError): + class X(O, type(None)): + pass + with self.assertRaises(TypeError): + class X(type(None), O): + pass + + class X(object): + pass + with self.assertRaises(TypeError): + X.__bases__ = type(None), + with self.assertRaises(TypeError): + X.__bases__ = object, type(None) + with self.assertRaises(TypeError): + X.__bases__ = type(None), object + with self.assertRaises(TypeError): + X.__bases__ = O, type(None) + with self.assertRaises(TypeError): + X.__bases__ = type(None), O def test_mutable_bases_with_failing_mro(self): # Testing mutable bases with failing mro... |