monkeypatch.setattr not sticking on a module imported with from x import y
pytest 8.0. I'm trying to patch a function that module A imports from module B. In my test I do monkeypatch.setattr('module_b.helper', fake) but module A still calls the real one. I read something about patching where the name is looked up versus where it's defined, but I don't fully get it. Can someone explain in plain English without the usual mock documentation jargon?
4 replies