In conftest (in standalone device):
monkeypatch.setattr('collector.util.download_data', lambda url:"Winning" )
In collector / util.py :
def download_data(url):
assert False
In the_caller.py :
from collector.util import download_data
def some_function():
download_data("blah")
When I call some_function (), I get assert. However, if I change the_caller.py to:
import collector
def some_function():
collector.util.download_data("blah")
then I get "Victory".
Why does this behave differently, and how can I make monkeypatch work for both scenarios?
source
share