mercredi 28 août 2019

How to patch a function imported from another module

Not able to patch the function.

I am trying to patch a function from another module in my test function. But I am not able to do that.

response.py

import boto3
lambda = boto3.client('lambda')

def response(event,context):
      s = boto3.client('s')




test_response.py

class lambda_handler(unittest.Testcae):
      @patch('response.boto3')
      test_handler():
       #doing the necessary assertions.

But the above mentioned one gives me the following error

botocore.exceptions.NoRegionError: You must specify a region.


The error is shown for the boto3.client declared outside the response function. Please help me in resolving this issue.

Aucun commentaire:

Enregistrer un commentaire