Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get rid of deprecated pytest.warns(None) usage #38027

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/providers/amazon/aws/hooks/test_emr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from __future__ import annotations

import re
import warnings
from unittest import mock

import boto3
Expand Down Expand Up @@ -167,7 +168,9 @@ def test_create_job_flow_extra_args(self):
# AmiVersion is really old and almost no one will use it anymore, but
# it's one of the "optional" request params that moto supports - it's
# coverage of EMR isn't 100% it turns out.
with pytest.warns(None): # Expected no warnings if ``emr_conn_id`` exists with correct conn_type
with warnings.catch_warnings():
# Expected no warnings if ``emr_conn_id`` exists with correct conn_type
warnings.simplefilter("error")
cluster = hook.create_job_flow({"Name": "test_cluster", "ReleaseLabel": "", "AmiVersion": "3.2"})
cluster = client.describe_cluster(ClusterId=cluster["JobFlowId"])["Cluster"]

Expand Down
6 changes: 4 additions & 2 deletions tests/providers/amazon/aws/utils/test_connection_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import os
import warnings
from dataclasses import fields
from unittest import mock

Expand Down Expand Up @@ -237,7 +238,8 @@ def test_get_session_kwargs_from_wrapper(
expected["profile_name"] = profile_name
if region_name:
expected["region_name"] = region_name
with pytest.warns(None):
with warnings.catch_warnings():
warnings.simplefilter("error") # Not expected any warnings here
wrap_conn = AwsConnectionWrapper(conn=mock_conn)
session_kwargs = wrap_conn.session_kwargs
assert session_kwargs == expected
Expand Down Expand Up @@ -354,7 +356,7 @@ def test_get_endpoint_url_from_extra(self, extra, expected):
" Please set extra['endpoint_url'] instead"
)

with pytest.warns(None) as records:
with warnings.catch_warnings(record=True) as records:
wrap_conn = AwsConnectionWrapper(conn=mock_conn)

if extra.get("host"):
Expand Down
5 changes: 3 additions & 2 deletions tests/www/test_init_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import re
import warnings
from unittest import mock

import pytest
Expand All @@ -37,6 +38,6 @@ def test_should_raise_deprecation_warning_when_enabled(self):
@conf_vars({("api", "enable_experimental_api"): "false"})
def test_should_not_raise_deprecation_warning_when_disabled(self):
app = mock.MagicMock()
with pytest.warns(None) as warnings:
with warnings.catch_warnings():
warnings.simplefilter("error") # Not expected any warnings here
init_views.init_api_experimental(app)
assert len(warnings) == 0