How to mock global modules
So, imagine if you want to mock an external dependency in a script, like this one that is connection to AWS
If you follow python documentation and apply for this case, will not work. For this case, you need to mock the module itself.
Unfortunately, I wasn’t able to mock boto3
entirely, but I can mock the client()
, this way:
And done :)