Skip to content

Instantly share code, notes, and snippets.

@akhundMurad
Created August 15, 2022 16:36
Show Gist options
  • Select an option

  • Save akhundMurad/dd20e384ac02051aadaf4a09b7dcef3c to your computer and use it in GitHub Desktop.

Select an option

Save akhundMurad/dd20e384ac02051aadaf4a09b7dcef3c to your computer and use it in GitHub Desktop.
DI with testing
def some_func(redis_client) -> dict:
data = redis_client.get(...)
# logic...
return data
class FakeRedisClient:
_storage = dict()
def get(key):
return self._storage[key]
def test_some_func() -> None:
result = some_func(FakeRedisClient())
assert result
redis_client = Redis(...)
def some_func() -> dict:
data = redis_client.get(...)
# logic...
return data
def test_some_func() -> None:
# Как мне тут проестить функцию не поднимая редис?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment