You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spying on a cached method through its class drops self #657
Spying on an instance method decorated with functools.lru_cache or functools.cache through its class breaks calls through an instance: the spy does not bind self, so a previously valid call raises TypeError. Spying on the instance directly works.
The second call raises TypeError: ...calculate() missing 1 required positional argument: 'value'. Expected: it returns 6, preserves caching, and records the instance and argument like a spy on an ordinary instance method.
Reproduced on Linux with Python 3.12.16 and pytest-mock main 163f3221165929d64ac6549f693ea34edeb2b95d, using both unittest.mock and the standalone mock backend.
Activity