@@ -174,9 +174,10 @@ def func():
174174def test_classmethod_not_guarded ():
175175 """Test that @classmethod (cls) does not trigger the instance method guard.
176176
177- Note: The decorator order must be @classmethod first, then @cachier,
178- so that cachier sees the underlying function (whose first param is
179- ``cls``, not ``self``) and the guard is not triggered.
177+ Note: Place ``@classmethod`` above ``@cachier`` so that ``@cachier``
178+ decorates the underlying function before it is wrapped as a classmethod.
179+ This way cachier sees ``cls`` (not ``self``) as the first parameter and
180+ the instance-method guard is not triggered.
180181
181182 """
182183
@@ -204,15 +205,18 @@ def method(cls, x):
204205@pytest .mark .smoke
205206def test_instance_method_global_opt_out_reset ():
206207 """Test that resetting allow_non_static_methods=False re-enables the guard."""
207- set_global_params (allow_non_static_methods = True )
208- set_global_params (allow_non_static_methods = False )
209- with pytest .raises (TypeError , match = "instance method" ):
210-
211- class Foo :
212- @cachier_decorator (backend = "memory" )
213- def method (self , x ):
214- return x
215-
208+ original = get_global_params ().allow_non_static_methods
209+ try :
210+ set_global_params (allow_non_static_methods = True )
211+ set_global_params (allow_non_static_methods = False )
212+ with pytest .raises (TypeError , match = "instance method" ):
213+
214+ class Foo :
215+ @cachier_decorator (backend = "memory" )
216+ def method (self , x ):
217+ return x
218+ finally :
219+ set_global_params (allow_non_static_methods = original )
216220
217221@pytest .mark .smoke
218222def test_instance_method_skip_cache ():
0 commit comments