From 9e1d78d44e7d4c60ecbaa876b0dd16b4be7127b6 Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Wed, 17 Aug 2022 14:01:22 +0000 Subject: [PATCH] TechDebt - remove warnings from tests (#5390) --- tests/test_ec2/test_instances.py | 6 +++--- tests/test_ec2/test_spot_instances.py | 2 ++ tests/test_emr/test_emr_boto3.py | 2 ++ tests/test_iot/test_iot_thing_groups.py | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_ec2/test_instances.py b/tests/test_ec2/test_instances.py index 8b4f3c6a4..8412e14d9 100644 --- a/tests/test_ec2/test_instances.py +++ b/tests/test_ec2/test_instances.py @@ -1,5 +1,6 @@ import base64 import ipaddress +import warnings from unittest import SkipTest, mock from uuid import uuid4 @@ -2303,15 +2304,14 @@ def test_create_instance_with_launch_template_id_produces_no_warning( LaunchTemplateName=str(uuid4()), LaunchTemplateData={"ImageId": EXAMPLE_AMI_ID} )["LaunchTemplate"] - with pytest.warns(None) as captured_warnings: + with warnings.catch_warnings(): + warnings.simplefilter("error") resource.create_instances( MinCount=1, MaxCount=1, LaunchTemplate={launch_template_kind: template[launch_template_kind]}, ) - assert len(captured_warnings) == 0 - @mock_ec2 def test_create_instance_from_launch_template__process_tags(): diff --git a/tests/test_ec2/test_spot_instances.py b/tests/test_ec2/test_spot_instances.py index 25c9d5128..e756deaa0 100644 --- a/tests/test_ec2/test_spot_instances.py +++ b/tests/test_ec2/test_spot_instances.py @@ -297,6 +297,7 @@ def test_get_all_spot_instance_requests_filtering(): @mock_ec2 +@pytest.mark.filterwarnings("ignore") def test_request_spot_instances_instance_lifecycle(): if settings.TEST_SERVER_MODE: # Currently no easy way to check which instance was created by request_spot_instance @@ -312,6 +313,7 @@ def test_request_spot_instances_instance_lifecycle(): @mock_ec2 +@pytest.mark.filterwarnings("ignore") def test_request_spot_instances_with_tags(): client = boto3.client("ec2", region_name="us-east-1") request = client.request_spot_instances( diff --git a/tests/test_emr/test_emr_boto3.py b/tests/test_emr/test_emr_boto3.py index 2a4aed97b..1ab2ffa1e 100644 --- a/tests/test_emr/test_emr_boto3.py +++ b/tests/test_emr/test_emr_boto3.py @@ -74,6 +74,7 @@ input_instance_groups = [ @mock_emr +@pytest.mark.filterwarnings("ignore") def test_describe_cluster(): region_name = "us-east-1" client = boto3.client("emr", region_name=region_name) @@ -251,6 +252,7 @@ def test_describe_job_flows(): @mock_emr +@pytest.mark.filterwarnings("ignore") def test_describe_job_flow(): client = boto3.client("emr", region_name="us-east-1") diff --git a/tests/test_iot/test_iot_thing_groups.py b/tests/test_iot/test_iot_thing_groups.py index fca1d23d6..e456f5c25 100644 --- a/tests/test_iot/test_iot_thing_groups.py +++ b/tests/test_iot/test_iot_thing_groups.py @@ -589,10 +589,12 @@ def test_thing_group_already_exists_with_same_properties_returned(): current_thing_group = client.create_thing_group( thingGroupName=thing_group_name, thingGroupProperties=thing_group_properties ) + current_thing_group.pop("ResponseMetadata") thing_group = client.create_thing_group( thingGroupName=thing_group_name, thingGroupProperties=thing_group_properties ) + thing_group.pop("ResponseMetadata") assert thing_group == current_thing_group