It’s really easy to cut the dependency with aiocache functionality:

import asyncio
from unittest.mock import MagicMock

from aiocache.base import BaseCache

async def main():
    mocked_cache = MagicMock(spec=BaseCache)
    mocked_cache.get.return_value = "world"
    print(await mocked_cache.get("hello"))

if __name__ == "__main__":

Note that we are passing the BaseCache as the spec for the Mock.

Also, for debuging purposes you can use AIOCACHE_DISABLE = 1 python myscript.py to disable caching.