From f50d80ede66af3bdac31758dad8c2e228142a12a Mon Sep 17 00:00:00 2001 From: nom3ad <19239479+nom3ad@users.noreply.github.com> Date: Mon, 18 Oct 2021 14:51:18 +0530 Subject: [PATCH] fix: invalid escape sequence DeprecationWarning (#4430) --- moto/athena/urls.py | 2 +- tests/test_ec2/test_tags.py | 6 +++--- tests/test_efs/test_file_system.py | 4 ++-- tests/test_iam/test_iam.py | 2 +- .../test_kinesisvideoarchivedmedia.py | 6 ++++-- tests/test_redshift/test_redshift.py | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/moto/athena/urls.py b/moto/athena/urls.py index c36c379cf..80540c7bb 100644 --- a/moto/athena/urls.py +++ b/moto/athena/urls.py @@ -1,6 +1,6 @@ from __future__ import unicode_literals from .responses import AthenaResponse -url_bases = ["https?://athena\.(.+)\.amazonaws\.com"] +url_bases = [r"https?://athena\.(.+)\.amazonaws\.com"] url_paths = {"{0}/$": AthenaResponse.dispatch} diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py index 3d0790271..2f9598972 100644 --- a/tests/test_ec2/test_tags.py +++ b/tests/test_ec2/test_tags.py @@ -561,9 +561,9 @@ def test_get_all_tags_value_filter_boto3(): filter_by_value("some*value", [instance_a.id, instance_b.id, image.id]) filter_by_value("*some*value", [instance_a.id, instance_b.id, image.id]) filter_by_value("*some*value*", [instance_a.id, instance_b.id, image.id]) - filter_by_value("*value\*", [instance_c.id]) - filter_by_value("*value\*\*", [instance_d.id]) - filter_by_value("*value\*\?", [instance_e.id]) + filter_by_value(r"*value\*", [instance_c.id]) + filter_by_value(r"*value\*\*", [instance_d.id]) + filter_by_value(r"*value\*\?", [instance_e.id]) # Has boto3 equivalent diff --git a/tests/test_efs/test_file_system.py b/tests/test_efs/test_file_system.py index a16528d19..15bf1f0e8 100644 --- a/tests/test_efs/test_file_system.py +++ b/tests/test_efs/test_file_system.py @@ -10,8 +10,8 @@ from botocore.exceptions import ClientError from moto import mock_efs from tests.test_efs.junk_drawer import has_status_code -ARN_PATT = "^arn:(?P[^:\n]*):(?P[^:\n]*):(?P[^:\n]*):(?P[^:\n]*):(?P(?P[^:\/\n]*)[:\/])?(?P.*)$" -STRICT_ARN_PATT = "^arn:aws:[a-z]+:[a-z]{2}-[a-z]+-[0-9]:[0-9]+:[a-z-]+\/[a-z0-9-]+$" +ARN_PATT = r"^arn:(?P[^:\n]*):(?P[^:\n]*):(?P[^:\n]*):(?P[^:\n]*):(?P(?P[^:\/\n]*)[:\/])?(?P.*)$" +STRICT_ARN_PATT = r"^arn:aws:[a-z]+:[a-z]{2}-[a-z]+-[0-9]:[0-9]+:[a-z-]+\/[a-z0-9-]+$" SAMPLE_1_PARAMS = { "CreationToken": "myFileSystem1", diff --git a/tests/test_iam/test_iam.py b/tests/test_iam/test_iam.py index febffbba2..eb6627df9 100644 --- a/tests/test_iam/test_iam.py +++ b/tests/test_iam/test_iam.py @@ -795,7 +795,7 @@ def test_set_default_policy_version(): VersionId="wrong_version_id", ).should.throw( ClientError, - "Value 'wrong_version_id' at 'versionId' failed to satisfy constraint: Member must satisfy regular expression pattern: v[1-9][0-9]*(\.[A-Za-z0-9-]*)?", + r"Value 'wrong_version_id' at 'versionId' failed to satisfy constraint: Member must satisfy regular expression pattern: v[1-9][0-9]*(\.[A-Za-z0-9-]*)?", ) # Set default version for non-existing version diff --git a/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py b/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py index ee4439197..6121ba843 100644 --- a/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py +++ b/tests/test_kinesisvideoarchivedmedia/test_kinesisvideoarchivedmedia.py @@ -25,7 +25,7 @@ def test_get_hls_streaming_session_url(): endpoint_url=data_endpoint, ) res = client.get_hls_streaming_session_url(StreamName=stream_name,) - reg_exp = "^{}/hls/v1/getHLSMasterPlaylist.m3u8\?SessionToken\=.+$".format( + reg_exp = r"^{}/hls/v1/getHLSMasterPlaylist.m3u8\?SessionToken\=.+$".format( data_endpoint ) res.should.have.key("HLSStreamingSessionURL").which.should.match(reg_exp) @@ -49,7 +49,9 @@ def test_get_dash_streaming_session_url(): endpoint_url=data_endpoint, ) res = client.get_dash_streaming_session_url(StreamName=stream_name,) - reg_exp = "^{}/dash/v1/getDASHManifest.mpd\?SessionToken\=.+$".format(data_endpoint) + reg_exp = r"^{}/dash/v1/getDASHManifest.mpd\?SessionToken\=.+$".format( + data_endpoint + ) res.should.have.key("DASHStreamingSessionURL").which.should.match(reg_exp) diff --git a/tests/test_redshift/test_redshift.py b/tests/test_redshift/test_redshift.py index 1edbb3d36..ce387a9b5 100644 --- a/tests/test_redshift/test_redshift.py +++ b/tests/test_redshift/test_redshift.py @@ -938,7 +938,7 @@ def test_create_invalid_cluster_subnet_group_boto3(): ) err = ex.value.response["Error"] err["Code"].should.equal("InvalidSubnet") - err["Message"].should.match("Subnet \[[a-z0-9-']+\] not found.") + err["Message"].should.match(r"Subnet \[[a-z0-9-']+\] not found.") # Has boto3 equivalent