@@ -3137,6 +3137,10 @@ def m1d(*args, **kwargs):
3137
3137
int ))
3138
3138
3139
3139
def test_signature_on_classmethod (self ):
3140
+ self .assertEqual (self .signature (classmethod ),
3141
+ ((('function' , ..., ..., "positional_only" ),),
3142
+ ...))
3143
+
3140
3144
class Test :
3141
3145
@classmethod
3142
3146
def foo (cls , arg1 , * , arg2 = 1 ):
@@ -3155,6 +3159,10 @@ def foo(cls, arg1, *, arg2=1):
3155
3159
...))
3156
3160
3157
3161
def test_signature_on_staticmethod (self ):
3162
+ self .assertEqual (self .signature (staticmethod ),
3163
+ ((('function' , ..., ..., "positional_only" ),),
3164
+ ...))
3165
+
3158
3166
class Test :
3159
3167
@staticmethod
3160
3168
def foo (cls , * , arg ):
@@ -3678,16 +3686,20 @@ class Bar(Spam, Foo):
3678
3686
((('a' , ..., ..., "positional_or_keyword" ),),
3679
3687
...))
3680
3688
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 ),
3685
3696
((('a' , ..., ..., "positional_or_keyword" ),),
3686
3697
...))
3687
3698
# wrapper loop:
3688
- Wrapped .__wrapped__ = Wrapped
3699
+ wrapper = Wrapper ()
3700
+ wrapper .__wrapped__ = wrapper
3689
3701
with self .assertRaisesRegex (ValueError , 'wrapper loop' ):
3690
- self .signature (Wrapped )
3702
+ self .signature (wrapper )
3691
3703
3692
3704
def test_signature_on_lambdas (self ):
3693
3705
self .assertEqual (self .signature ((lambda a = 10 : a )),
@@ -4999,6 +5011,14 @@ def test_recursion_limit(self):
4999
5011
with self .assertRaisesRegex (ValueError , 'wrapper loop' ):
5000
5012
inspect .unwrap (obj )
5001
5013
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
+
5002
5022
class TestMain (unittest .TestCase ):
5003
5023
def test_only_source (self ):
5004
5024
module = importlib .import_module ('unittest' )
0 commit comments