From 1472d63c877471996e3798fcdc6144665e57121c Mon Sep 17 00:00:00 2001 From: Chris Keogh Date: Wed, 13 Sep 2017 08:28:42 +1200 Subject: [PATCH] use assert_raises teat helper pattern --- tests/test_dynamodb2/test_dynamodb.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/test_dynamodb2/test_dynamodb.py b/tests/test_dynamodb2/test_dynamodb.py index 3b50f0b8e..764980fba 100644 --- a/tests/test_dynamodb2/test_dynamodb.py +++ b/tests/test_dynamodb2/test_dynamodb.py @@ -164,7 +164,7 @@ def test_item_add_empty_string_exception(): AttributeDefinitions=[{'AttributeName':'forum_name','AttributeType':'S'}], ProvisionedThroughput={'ReadCapacityUnits':5,'WriteCapacityUnits':5}) - try: + with assert_raises(ClientError) as ex: conn.put_item( TableName=name, Item={ @@ -176,6 +176,8 @@ def test_item_add_empty_string_exception(): } ) - except ClientError as exception: - exception.response['Error']['Code'] - assert exception.response['Error']['Code'] == "ValidationException" + ex.exception.response['Error']['Code'].should.equal('ValidationException') + ex.exception.response['ResponseMetadata']['HTTPStatusCode'].should.equal(400) + ex.exception.response['Error']['Message'].should.equal( + 'One or more parameter values were invalid: An AttributeValue may not contain an empty string' + )