Mocking a function within a Python Flask Blueprint Mocking a function within a Python Flask Blueprint flask flask

Mocking a function within a Python Flask Blueprint


When I ran into this problem it was because api was a blueprint. Instead of looking for the configs.py under the folder api the mocker was looking for something called utils in the blueprint api.

To get around this I imported the py file and patched the object directly:

from app.api import utils@patch.object(utils, 'is_file_writeable', lambda x: False)