diff --git a/awscli/shorthand.py b/awscli/shorthand.py index 18ec091f717a..f8e51168e183 100644 --- a/awscli/shorthand.py +++ b/awscli/shorthand.py @@ -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()}" ) diff --git a/tests/unit/test_shorthand.py b/tests/unit/test_shorthand.py index 8d748d423a0b..8c4f3c49a0be 100644 --- a/tests/unit/test_shorthand.py +++ b/tests/unit/test_shorthand.py @@ -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 \