@pytest.fixture(params=['proxy', 'layered', 'memory', 'file', 'serialised'])
def cache(request):
    'Return cache.'
    if (request.param == 'proxy'):
        cache = ftrack_api.cache.ProxyCache(ftrack_api.cache.MemoryCache())
    elif (request.param == 'layered'):
        cache = ftrack_api.cache.LayeredCache([ftrack_api.cache.MemoryCache()])
    elif (request.param == 'memory'):
        cache = ftrack_api.cache.MemoryCache()
    elif (request.param == 'file'):
        cache_path = os.path.join(tempfile.gettempdir(), '{0}.dbm'.format(uuid.uuid4().hex))
        cache = ftrack_api.cache.FileCache(cache_path)

        def cleanup():
            'Cleanup.'
            try:
                os.remove(cache_path)
            except OSError:
                os.remove((cache_path + '.db'))
        request.addfinalizer(cleanup)
    elif (request.param == 'serialised'):
        cache = ftrack_api.cache.SerialisedCache(ftrack_api.cache.MemoryCache(), encode=(lambda value: value), decode=(lambda value: value))
    else:
        raise ValueError('Unrecognised cache fixture type {0!r}'.format(request.param))
    return cache
Return cache.
@pytest.fixture(params=['proxy', 'layered', 'memory', 'file', 'serialised'])
def cache(request):
    
    if (request.param == 'proxy'):
        cache = ftrack_api.cache.ProxyCache(ftrack_api.cache.MemoryCache())
    elif (request.param == 'layered'):
        cache = ftrack_api.cache.LayeredCache([ftrack_api.cache.MemoryCache()])
    elif (request.param == 'memory'):
        cache = ftrack_api.cache.MemoryCache()
    elif (request.param == 'file'):
        cache_path = os.path.join(tempfile.gettempdir(), '{0}.dbm'.format(uuid.uuid4().hex))
        cache = ftrack_api.cache.FileCache(cache_path)

        def cleanup():
            'Cleanup.'
            try:
                os.remove(cache_path)
            except OSError:
                os.remove((cache_path + '.db'))
        request.addfinalizer(cleanup)
    elif (request.param == 'serialised'):
        cache = ftrack_api.cache.SerialisedCache(ftrack_api.cache.MemoryCache(), encode=(lambda value: value), decode=(lambda value: value))
    else:
        raise ValueError('Unrecognised cache fixture type {0!r}'.format(request.param))
    return cache