Skip to content
Merged
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
16 changes: 14 additions & 2 deletions tavern/_core/dict_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,13 @@ def _check_and_format_values(to_format: str, box_vars: Box) -> str:
Formatted string with variables replaced by their values
"""
formatter = string.Formatter()
would_format = formatter.parse(to_format)
try:
would_format = list(formatter.parse(to_format))
except ValueError as e:
raise exceptions.BadSchemaError(
f"Format string '{to_format}' contains invalid syntax (unmatched '{{' or '}}')."
" Escape literal braces as '{{{{' and '}}}}' if they are not format placeholders."
) from e

for _, field_name, _, _ in would_format:
if field_name is None:
Expand Down Expand Up @@ -92,7 +98,13 @@ def _attempt_find_include(to_format: str, box_vars: box.Box) -> str | None:
The retrieved value after applying any conversion, or None if not found
"""
formatter = string.Formatter()
would_format = list(formatter.parse(to_format))
try:
would_format = list(formatter.parse(to_format))
except ValueError as e:
raise exceptions.BadSchemaError(
f"Format string '{to_format}' contains invalid syntax (unmatched '{{' or '}}')."
" Escape literal braces as '{{{{' and '}}}}' if they are not format placeholders."
) from e

yaml_tag = ForceIncludeToken.yaml_tag

Expand Down
Loading