Files
DeepTutor/tests/agents/visualize/test_extract_code_block.py
santhreal 5d5c2ef36e fix(visualize): allow code fences without a blank closing line
Models often close a fenced block on the same line as the last content.
Require only an optional newline before the closing fence so mermaid and
chart payloads are extracted instead of returned still-fenced.
2026-07-22 22:49:05 -07:00

17 lines
588 B
Python

"""Regression tests for visualize.utils.extract_code_block."""
from __future__ import annotations
from deeptutor.agents.visualize.utils import extract_code_block
def test_extract_code_block_closing_fence_without_leading_newline() -> None:
raw = "```mermaid\ngraph TD\n A-->B```"
assert extract_code_block(raw, "mermaid") == "graph TD\n A-->B"
assert extract_code_block(raw) == "graph TD\n A-->B"
def test_extract_code_block_normal_fenced_block() -> None:
raw = "```javascript\nconst x = 1;\n```"
assert extract_code_block(raw, "javascript") == "const x = 1;"