Port test suite from nose to pytest.

This just eliminates all errors on the tests collection. Elimination of
failures is left to the next commit.
This commit is contained in:
Matěj Cepl 2020-10-06 07:54:49 +02:00
commit 77dc60ea97
146 changed files with 1172 additions and 1277 deletions

View file

@ -0,0 +1 @@
# This file is intentionally left blank.

View file

@ -10,7 +10,7 @@ import sure # noqa
import responses
from botocore.exceptions import ClientError
from nose.tools import assert_raises
import pytest
from moto import mock_sns, mock_sqs, settings
from moto.core import ACCOUNT_ID
from moto.sns import sns_backend
@ -233,13 +233,13 @@ def test_publish_bad_sms():
client = boto3.client("sns", region_name="us-east-1")
# Test invalid number
with assert_raises(ClientError) as cm:
with pytest.raises(ClientError) as cm:
client.publish(PhoneNumber="NAA+15551234567", Message="my message")
cm.exception.response["Error"]["Code"].should.equal("InvalidParameter")
cm.exception.response["Error"]["Message"].should.contain("not meet the E164")
# Test to long ASCII message
with assert_raises(ClientError) as cm:
with pytest.raises(ClientError) as cm:
client.publish(PhoneNumber="+15551234567", Message="a" * 1601)
cm.exception.response["Error"]["Code"].should.equal("InvalidParameter")
cm.exception.response["Error"]["Message"].should.contain("must be less than 1600")
@ -387,7 +387,7 @@ def test_publish_message_too_long():
sns = boto3.resource("sns", region_name="us-east-1")
topic = sns.create_topic(Name="some-topic")
with assert_raises(ClientError):
with pytest.raises(ClientError):
topic.publish(Message="".join(["." for i in range(0, 262145)]))
# message short enough - does not raise an error

View file

@ -5,7 +5,7 @@ import json
import sure # noqa
from botocore.exceptions import ClientError
from nose.tools import assert_raises
import pytest
from moto import mock_sns, mock_sqs
from moto.sns.models import (
@ -293,7 +293,7 @@ def test_creating_subscription_with_attributes():
subscriptions.should.have.length_of(0)
# invalid attr name
with assert_raises(ClientError):
with pytest.raises(ClientError):
conn.subscribe(
TopicArn=topic_arn,
Protocol="http",
@ -387,17 +387,17 @@ def test_set_subscription_attributes():
attrs["Attributes"]["FilterPolicy"].should.equal(filter_policy)
# not existing subscription
with assert_raises(ClientError):
with pytest.raises(ClientError):
conn.set_subscription_attributes(
SubscriptionArn="invalid",
AttributeName="RawMessageDelivery",
AttributeValue="true",
)
with assert_raises(ClientError):
with pytest.raises(ClientError):
attrs = conn.get_subscription_attributes(SubscriptionArn="invalid")
# invalid attr name
with assert_raises(ClientError):
with pytest.raises(ClientError):
conn.set_subscription_attributes(
SubscriptionArn=subscription_arn,
AttributeName="InvalidName",
@ -502,7 +502,7 @@ def test_check_opted_out_invalid():
conn = boto3.client("sns", region_name="us-east-1")
# Invalid phone number
with assert_raises(ClientError):
with pytest.raises(ClientError):
conn.check_if_phone_number_is_opted_out(phoneNumber="+44742LALALA")