@@ -265,6 +265,45 @@ def bar(): return 42
265265 self .assertEqual (bar (), 42 )
266266 self .assertEqual (actions , expected_actions )
267267
268+ def test_wrapped_descriptor_inside_classmethod (self ):
269+ class BoundWrapper :
270+ def __init__ (self , wrapped ):
271+ self .__wrapped__ = wrapped
272+
273+ def __call__ (self , * args , ** kwargs ):
274+ return self .__wrapped__ (* args , ** kwargs )
275+
276+ class Wrapper :
277+ def __init__ (self , wrapped ):
278+ self .__wrapped__ = wrapped
279+
280+ def __get__ (self , instance , owner ):
281+ bound_function = self .__wrapped__ .__get__ (instance , owner )
282+ return BoundWrapper (bound_function )
283+
284+ def decorator (wrapped ):
285+ return Wrapper (wrapped )
286+
287+ class Class :
288+ @decorator
289+ @classmethod
290+ def inner (cls ):
291+ # This should already work.
292+ return 'spam'
293+
294+ @classmethod
295+ @decorator
296+ def outer (cls ):
297+ # Raised TypeError with a message saying that the 'Wrapper'
298+ # object is not callable.
299+ return 'eggs'
300+
301+ self .assertEqual (Class .inner (), 'spam' )
302+ self .assertEqual (Class .outer (), 'eggs' )
303+ self .assertEqual (Class ().inner (), 'spam' )
304+ self .assertEqual (Class ().outer (), 'eggs' )
305+
306+
268307class TestClassDecorators (unittest .TestCase ):
269308
270309 def test_simple (self ):
0 commit comments