Skip to content

Commit

Permalink
refactor: Standardise Python open parenthesesis error
Browse files Browse the repository at this point in the history
  • Loading branch information
kieran-ryan committed Jan 13, 2025
1 parent 1286aa8 commit fce5356
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion python/cucumber_tag_expressions/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ def ensure_expected_token_type(token_type, index):
last_operation = operations.pop()
if last_operation is Token.OPEN_PARENTHESIS:
# -- CASE: TOO MANY OPEN-PARENTHESIS
message = "Unclosed '(': Too many open-parens in: %s" % text
message = (
'Tag expression "%s" could not be parsed because of syntax error:'
' Unmatched (.' % text
)
raise TagExpressionError(message)
cls._push_expression(last_operation, expressions)

Expand Down
2 changes: 1 addition & 1 deletion python/tests/unit/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def test_parse__with_escape_repr(self, text, expected):
# -- BAD CASES:
@pytest.mark.parametrize("text, error_message", [
("( a and b ))", "Missing '(': Too few open-parens"),
("( ( a and b )", "Unclosed '(': Too many open-parens"),
("( ( a and b )", "Unmatched (."),
])
def test_parse__fails_with_unbalanced_parens(self, text, error_message):
self.assert_parse_with_error_contains_message(text, error_message)
Expand Down

0 comments on commit fce5356

Please sign in to comment.