Hello I have the following code;
I am trying to test the load function inside file_a; download is function in an external module I imported
file_a.py
from foo import download
class Bar()
__init__(self, arg_1):
self.var = arg_1
def load(self):
if self.var == "latest_lib":
download("latest_lib")
I wrote the test like
test.py
@patch(file_a.download)
def test_download():
import file_a
bar = file_a.Bar("latest_lib")
bar.load()
file_a.download.assert_called()
But it seems like the bar object is not calling the mock download rather the imported download. How can I fix this problem and make my test pass?