@@ -3137,6 +3137,10 @@ def m1d(*args, **kwargs):
31373137 int ))
31383138
31393139 def test_signature_on_classmethod (self ):
3140+ self .assertEqual (self .signature (classmethod ),
3141+ ((('function' , ..., ..., "positional_only" ),),
3142+ ...))
3143+
31403144 class Test :
31413145 @classmethod
31423146 def foo (cls , arg1 , * , arg2 = 1 ):
@@ -3155,6 +3159,10 @@ def foo(cls, arg1, *, arg2=1):
31553159 ...))
31563160
31573161 def test_signature_on_staticmethod (self ):
3162+ self .assertEqual (self .signature (staticmethod ),
3163+ ((('function' , ..., ..., "positional_only" ),),
3164+ ...))
3165+
31583166 class Test :
31593167 @staticmethod
31603168 def foo (cls , * , arg ):
@@ -3678,16 +3686,20 @@ class Bar(Spam, Foo):
36783686 ((('a' , ..., ..., "positional_or_keyword" ),),
36793687 ...))
36803688
3681- class Wrapped :
3682- pass
3683- Wrapped .__wrapped__ = lambda a : None
3684- self .assertEqual (self .signature (Wrapped ),
3689+ def test_signature_on_wrapper (self ):
3690+ class Wrapper :
3691+ def __call__ (self , b ):
3692+ pass
3693+ wrapper = Wrapper ()
3694+ wrapper .__wrapped__ = lambda a : None
3695+ self .assertEqual (self .signature (wrapper ),
36853696 ((('a' , ..., ..., "positional_or_keyword" ),),
36863697 ...))
36873698 # wrapper loop:
3688- Wrapped .__wrapped__ = Wrapped
3699+ wrapper = Wrapper ()
3700+ wrapper .__wrapped__ = wrapper
36893701 with self .assertRaisesRegex (ValueError , 'wrapper loop' ):
3690- self .signature (Wrapped )
3702+ self .signature (wrapper )
36913703
36923704 def test_signature_on_lambdas (self ):
36933705 self .assertEqual (self .signature ((lambda a = 10 : a )),
@@ -4999,6 +5011,14 @@ def test_recursion_limit(self):
49995011 with self .assertRaisesRegex (ValueError , 'wrapper loop' ):
50005012 inspect .unwrap (obj )
50015013
5014+ def test_wrapped_descriptor (self ):
5015+ self .assertIs (inspect .unwrap (NTimesUnwrappable ), NTimesUnwrappable )
5016+ self .assertIs (inspect .unwrap (staticmethod ), staticmethod )
5017+ self .assertIs (inspect .unwrap (classmethod ), classmethod )
5018+ self .assertIs (inspect .unwrap (staticmethod (classmethod )), classmethod )
5019+ self .assertIs (inspect .unwrap (classmethod (staticmethod )), staticmethod )
5020+
5021+
50025022class TestMain (unittest .TestCase ):
50035023 def test_only_source (self ):
50045024 module = importlib .import_module ('unittest' )
0 commit comments