Close #14857: fix regression in references to PEP 3135 implicit __class__ closure variable. Reopens issue #12370, but also updates unittest.mock to workaround that issue
diff --git a/Lib/test/test_super.py b/Lib/test/test_super.py
index 298cae0..32eb1c0 100644
--- a/Lib/test/test_super.py
+++ b/Lib/test/test_super.py
@@ -81,6 +81,7 @@
self.assertEqual(E().f(), 'AE')
+ @unittest.expectedFailure
def test___class___set(self):
# See issue #12370
class X(A):
@@ -91,6 +92,29 @@
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_main():
support.run_unittest(TestSuper)