def test_fn_decorator(self): acr = self._fixture() reg = CacheRegion(async_creation_runner=acr) reg.configure("mock", expiration_time=5) canary = mock.Mock() @reg.cache_on_arguments() def go(x, y): canary(x, y) return x + y eq_(go(1, 2), 3) eq_(go(1, 2), 3) eq_(canary.mock_calls, [mock.call(1, 2)]) eq_(go(3, 4), 7) eq_(canary.mock_calls, [mock.call(1, 2), mock.call(3, 4)]) reg.invalidate(hard=False) eq_(go(1, 2), 3) eq_( canary.mock_calls, [mock.call(1, 2), mock.call(3, 4), mock.call(1, 2)], ) eq_( acr.mock_calls, [ mock.call( reg, "tests.cache.test_region:go|1 2", mock.ANY, reg._mutex("tests.cache.test_region:go|1 2"), ) ], )