I'm trying to write a unit test to coverage the raise of a exception, this is the code:
def delete_item(key, dynamodb=None):
table = get_table(dynamodb)
# delete the todo from the database
try:
table.delete_item(
Key={
'id': key
}
)
except ClientError as e:
print(e.response['Error']['Message'])
else:
return
I'm trying to coverage this exception with the following sentence in my unit test:
with self.assertRaises(ClientError):
self.table.delete_item(Key={'id': ''})
but I'm getting the following error:
AssertionError: ClientError not raised
Could anybody help me?
Thanks.