Hello I'm trying the following test scenario
def test_main(monkeypatch):
with patch("library.mockme.MockMe") as mock:
message = MainObejct().message()
assert message == "Mock me"
MainObject implementation
from library.mockme import MockMe
class MainObejct():
def __init__(self):
self.mock_me = MockMe()
def message(self):
return self.mock_me.message
The problem here is that the MockMe object is not patched... but if I change the import to from library import mockme.MockMe it actually works, is there a way to make it work with my original implementation?
Thanks!