diff options
Diffstat (limited to 'Lib/test/test_super.py')
-rw-r--r-- | Lib/test/test_super.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Lib/test/test_super.py b/Lib/test/test_super.py index 914216d..f6469cf 100644 --- a/Lib/test/test_super.py +++ b/Lib/test/test_super.py @@ -81,6 +81,55 @@ class TestSuper(unittest.TestCase): self.assertEqual(E().f(), 'AE') + @unittest.expectedFailure + def test___class___set(self): + # See issue #12370 + class X(A): + def f(self): + return super().f() + __class__ = 413 + x = X() + self.assertEqual(x.f(), 'A') + self.assertEqual(x.__class__, 413) + + def test___class___instancemethod(self): + # See issue #14857 + class X: + def f(self): + return __class__ + self.assertIs(X().f(), X) + + def test___class___classmethod(self): + # See issue #14857 + class X: + @classmethod + def f(cls): + return __class__ + self.assertIs(X.f(), X) + + def test___class___staticmethod(self): + # See issue #14857 + class X: + @staticmethod + def f(): + return __class__ + self.assertIs(X.f(), X) + + def test_obscure_super_errors(self): + def f(): + super() + self.assertRaises(RuntimeError, f) + def f(x): + del x + super() + self.assertRaises(RuntimeError, f, None) + class X: + def f(x): + nonlocal __class__ + del __class__ + super() + self.assertRaises(RuntimeError, X().f) + def test_main(): support.run_unittest(TestSuper) |