File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 33import typing
44import unittest
55import warnings
6+ from test import support
67
78
89def global_function ():
@@ -478,6 +479,33 @@ def test_builtin__qualname__(self):
478479 self .assertEqual ([1 , 2 , 3 ].append .__qualname__ , 'list.append' )
479480 self .assertEqual ({'foo' : 'bar' }.pop .__qualname__ , 'dict.pop' )
480481
482+ @support .cpython_only
483+ def test_builtin__self__ (self ):
484+ # See https://github.com/python/cpython/issues/58211.
485+ import builtins
486+ import time
487+
488+ # builtin function:
489+ self .assertIs (len .__self__ , builtins )
490+ self .assertIs (time .sleep .__self__ , time )
491+
492+ # builtin classmethod:
493+ self .assertIs (dict .fromkeys .__self__ , dict )
494+ self .assertIs (float .__getformat__ .__self__ , float )
495+
496+ # builtin staticmethod:
497+ self .assertIsNone (str .maketrans .__self__ )
498+ self .assertIsNone (bytes .maketrans .__self__ )
499+
500+ # builtin bound instance method:
501+ l = [1 , 2 , 3 ]
502+ self .assertIs (l .append .__self__ , l )
503+
504+ d = {'foo' : 'bar' }
505+ self .assertEqual (d .pop .__self__ , d )
506+
507+ self .assertIsNone (None .__repr__ .__self__ )
508+
481509
482510if __name__ == "__main__" :
483511 unittest .main ()
You can’t perform that action at this time.
0 commit comments