I have code like this:
a.py
from app.cache import Cache
my_cache = Cache(cache_prefix='xxxxx')
b.py
from a import my_cache
class MyApp:
def run_app():
my_cache.get(1,2)
test_b.py
from mock import Mock, patch
import b
mock_my_cache_get= Mock(b.my_cache.get)
class MyTests():
@patch('b.my_cache.get', mock_my_cache_get)
def test_cache(self):
b.MyApp().run_app()
mock_my_cache_get.assert_called_with(1,2)
As you can see above, I am trying to write a unit test where I mock the get method of the class instance of Cache. However, when I try to assert that this mocked method is called with the specified arguments, I get an error saying that call is not found. Which, as iis obvious that is is.