def test_decorator_for_cache_key_multi_args_complex_object(self):
        """ caching a key built from attributes of an object passed as an argument
        """

        @supycache.supycache(cache_key='{0}_{arg.name}')
        def simple_function(positional, call_count, arg):
            return '%d:cached_value' % call_count

        class DummyArg:
            def __init__(self, value):
                self.name = value

        simple_function('some', 1, arg=DummyArg('key'))
        self.assertTrue(self.backend.get('some_key') == '1:cached_value')

        simple_function('some', 2, arg=DummyArg('key'))
        self.assertTrue(self.backend.get('some_key') == '1:cached_value')

        simple_function('some_other', 1, arg=DummyArg('new_key'))
        self.assertTrue(self.backend.get('some_other_new_key') == '1:cached_value')
dataset/ETHPy150Open lonetwin/supycache/tests/test_supycache.py/TestCacheDecorators.test_decorator_for_cache_key_multi_args_complex_object/original