mock.patch can't intercept requests.get in a Django view helper
Django 5.0, Python 3.12, unittest style tests. My view uses requests.get. In the test I do @patch('requests.get') and it works fine. But when I moved the call into a helper in another module, the same patch doesn't intercept it anymore. I'm confused about the string path and whether Django's app registry changes anything. It's probably a simple namespace thing but I can't see it.
4 replies