Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
test: cover escaped basic-string fallback when body has triple-quotes…
… and ends with single-quote

Addresses review feedback from PR #2115: adds test for the branch
where the body contains '"""' and ends with "'", which forces
_render_toml_string() through the escaped basic-string fallback
instead of the '''...''' literal-string path (since ''''  would
produce the same ambiguous-closing-delimiter problem).
  • Loading branch information
mnriem committed Apr 7, 2026
commit 4c2be675fcdc881193ef772dc8b5b4983f45821f
28 changes: 28 additions & 0 deletions tests/integrations/test_integration_base_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,34 @@ def test_toml_no_ambiguous_closing_quotes(self, tmp_path, monkeypatch):
assert parsed["prompt"].endswith('specified?"')
assert not parsed["prompt"].endswith("\n"), "parsed value must not gain a trailing newline"

def test_toml_triple_double_and_single_quote_ending(self, tmp_path, monkeypatch):
"""Body containing `\"\"\"` and ending with `'` falls back to escaped basic string."""
i = get_integration(self.KEY)
template = tmp_path / "sample.md"
template.write_text(
"---\n"
"description: Test\n"
"scripts:\n"
" sh: echo ok\n"
"---\n"
'Use """triple""" quotes\n'
"and end with 'single'\n",
encoding="utf-8",
)
monkeypatch.setattr(i, "list_command_templates", lambda: [template])

m = IntegrationManifest(self.KEY, tmp_path)
created = i.setup(tmp_path, m)
cmd_files = [f for f in created if "scripts" not in f.parts]
assert len(cmd_files) == 1

raw = cmd_files[0].read_text(encoding="utf-8")
assert "''''" not in raw, "literal string must not produce ambiguous closing quotes"
parsed = tomllib.loads(raw)
assert parsed["prompt"].endswith("'single'")
assert '"""triple"""' in parsed["prompt"]
assert not parsed["prompt"].endswith("\n"), "parsed value must not gain a trailing newline"

Comment thread
mnriem marked this conversation as resolved.
def test_toml_closing_delimiter_inline_when_safe(self, tmp_path, monkeypatch):
"""Body NOT ending with `"` keeps closing `\"\"\"` inline (no extra newline)."""
i = get_integration(self.KEY)
Expand Down
Loading