mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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
This commit is contained in:
parent
5c6eba3a93
commit
0b43bcf528
7 changed files with 45 additions and 17 deletions
|
@ -81,6 +81,7 @@ class TestSuper(unittest.TestCase):
|
|||
|
||||
self.assertEqual(E().f(), 'AE')
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test___class___set(self):
|
||||
# See issue #12370
|
||||
class X(A):
|
||||
|
@ -91,6 +92,29 @@ class TestSuper(unittest.TestCase):
|
|||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue