Skip to content

Commit

Permalink
fix(asgilook): ensure that no FakeRedis state persists between tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 committed Aug 11, 2023
1 parent 0e96f88 commit 6947190
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion examples/asgilook/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ def storage_path(tmpdir_factory):

@pytest.fixture
def client(predictable_uuid, storage_path):
# NOTE(vytas): Unlike the sync FakeRedis, fakeredis.aioredis.FakeRedis
# seems to share a global state in 2.17.0 (by design or oversight).
# Make sure we initialize a new fake server for every test case.
def fake_redis_from_url(*args, **kwargs):
server = fakeredis.FakeServer()
return fakeredis.aioredis.FakeRedis(server=server)

config = Config()
config.redis_from_url = fakeredis.aioredis.FakeRedis.from_url
config.redis_from_url = fake_redis_from_url
config.redis_host = 'redis://localhost'
config.storage_path = storage_path
config.uuid_generator = predictable_uuid
Expand Down

0 comments on commit 6947190

Please sign in to comment.