I am a complete newb when it comes to writing Python, let alone testing it.
Here is my Flask endpoint:
@blueprint.route(\'/mailing_finish/
You imported sumall_redis
as a local name in your view module, but mock the original sumall.utils.sumall_redis
.
You probably have this at the top of your view module:
from sumall.utils import sumall_redis
This binds that object to a local name in the module. When the test starts and the patch is applied, only the original sumall_redis
object in the sumall.utils
module will be affected, not this local name.
You'll need to mock the name bound in your view module instead:
@mock.patch('view_module.sumall_redis')
This applies to your other 2 imports as well.
The mock
documentation includes a guide on where to patch that you might want to read.