Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion awscli/shorthand.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, value, expected, actual, index):
def _construct_msg(self):
return (
f"Expected: '{self.expected}', received: '{self.actual}' "
f"for input:\n" "{self._error_location()}"
f"for input:\n{self._error_location()}"
)


Expand Down
11 changes: 11 additions & 0 deletions tests/unit/test_shorthand.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@ def test_error_parsing(expr):
shorthand.ShorthandParser().parse(expr)


def test_shorthand_parse_syntax_error_includes_caret():
"""Regression: message must interpolate _error_location(), not print the placeholder."""
with pytest.raises(shorthand.ShorthandParseSyntaxError) as exc:
shorthand.ShorthandParser().parse("a=b,c==d")
msg = str(exc.value)
assert "{self._error_location()}" not in msg
assert "Expected: ',', received: '=' for input:" in msg
assert "a=b,c==d" in msg
assert "^" in msg


@pytest.mark.parametrize(
"expr", (
# starting with " but unclosed, then repeated \
Expand Down