Skip to content

Commit ac27136

Browse files
authored
Fix all warnings in tests (#2303)
* Fix all warnings in tests * Black reformat
1 parent 749634d commit ac27136

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ addopts = --cov samtranslator --cov-report term-missing --cov-fail-under 95
55
testpaths = tests
66
env =
77
AWS_DEFAULT_REGION = ap-southeast-1
8+
markers =
9+
slow: marks tests as slow (deselect with '-m "not slow"')
810

requirements/dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ flake8~=3.8.4
33
tox~=3.24
44
pytest-cov~=2.10.1
55
pytest-xdist~=2.5
6+
pytest-env~=0.6.2
67
pylint>=1.7.2,<2.0
78
pyyaml~=5.4
89

samtranslator/intrinsics/actions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,8 +370,8 @@ def handler_method(full_ref, ref_value):
370370
"""
371371

372372
# RegExp to find pattern "${logicalId.property}" and return the word inside bracket
373-
logical_id_regex = "[A-Za-z0-9\.]+|AWS::[A-Z][A-Za-z]*"
374-
ref_pattern = re.compile(r"\$\{(" + logical_id_regex + ")\}")
373+
logical_id_regex = r"[A-Za-z0-9\.]+|AWS::[A-Z][A-Za-z]*"
374+
ref_pattern = re.compile(r"\$\{(" + logical_id_regex + r")\}")
375375

376376
# Find all the pattern, and call the handler to decide how to substitute them.
377377
# Do the substitution and return the final text

samtranslator/metrics/metrics.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ def __init__(self, namespace="ServerlessTransform", metrics_publisher=None):
125125
def __del__(self):
126126
if len(self.metrics_cache) > 0:
127127
# attempting to publish if user forgot to call publish in code
128-
LOG.warn("There are unpublished metrics. Please make sure you call publish after you record all metrics.")
128+
LOG.warning(
129+
"There are unpublished metrics. Please make sure you call publish after you record all metrics."
130+
)
129131
self.publish()
130132

131133
def _record_metric(self, name, value, unit, dimensions=None):

samtranslator/model/eventsources/push.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ def _add_swagger_integration(self, api, function, intrinsics_resolver):
831831

832832
parameter_name, parameter_value = next(iter(parameter.items()))
833833

834-
if not re.match("method\.request\.(querystring|path|header)\.", parameter_name):
834+
if not re.match(r"method\.request\.(querystring|path|header)\.", parameter_name):
835835
raise InvalidEventException(
836836
self.relative_id,
837837
"Invalid value for 'RequestParameters' property. Keys must be in the format "
@@ -855,7 +855,7 @@ def _add_swagger_integration(self, api, function, intrinsics_resolver):
855855
parameters.append(settings)
856856

857857
elif isinstance(parameter, str):
858-
if not re.match("method\.request\.(querystring|path|header)\.", parameter):
858+
if not re.match(r"method\.request\.(querystring|path|header)\.", parameter):
859859
raise InvalidEventException(
860860
self.relative_id,
861861
"Invalid value for 'RequestParameters' property. Keys must be in the format "

samtranslator/open_api/open_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def get_integration_function_logical_id(self, path_name, method_name):
107107
arn = uri.get("Fn::Sub", "")
108108

109109
# Extract lambda integration (${LambdaName.Arn}) and split ".Arn" off from it
110-
regex = "([A-Za-z0-9]+\.Arn)"
110+
regex = r"([A-Za-z0-9]+\.Arn)"
111111
matches = re.findall(regex, arn)
112112
# Prevent IndexError when integration URI doesn't contain .Arn (e.g. a Function with
113113
# AutoPublishAlias translates to AWS::Lambda::Alias, which make_shorthand represents

0 commit comments

Comments
 (0)