Fix Python – Mocking boto3 S3 client method Python

I’m trying to mock a singluar method from the boto3 s3 client object to throw an exception. But I need all other methods for this class to work as normal.
This is so I can test a singular Exception test when and error occurs performing a upload_part_copy
1st Attempt
import boto3
from mock import patch

with patch(‘botocore.client.S3.upload_part_co….

Fix Python – How to capture botocore’s NoSuchKey exception?

I’m trying to write “good” python and capture a S3 no such key error with this:
session = botocore.session.get_session()
client = session.create_client(‘s3’)
client.get_object(Bucket=BUCKET, Key=FILE)
except NoSuchKey as e:
print >> sys.stderr, “no such key in bucket”

But NoSuchKey isn’t defined and I can’t trace it to the import I n….