Skip to content
Open
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
9 changes: 9 additions & 0 deletions tests/unit/test_shorthand.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ def test_error_parsing(expr):
shorthand.ShorthandParser().parse(expr)


def test_error_parsing_message_includes_caret():
"""Error message should include the caret pointing at the parse failure position."""
with pytest.raises(shorthand.ShorthandParseError) as exc_info:
shorthand.ShorthandParser().parse("a=b,c==d")
msg = str(exc_info.value)
assert "a=b,c==d" in msg
assert "^" in msg


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