Files
DeepTutor/tests/services/test_mastery_hints.py
Marcello Pichini 318619e713 fix(mastery): keep apostrophes in study ask-hints (#2851)
The sanitizer deleted every quote character to unwrap a quoted reply,
so "What's ...?" was shown as "Whats ...?". Only unwrap a matching
outer pair, as the chat and reading hints already do.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 17:51:54 +08:00

37 lines
1.4 KiB
Python

"""Focused tests for the mastery study composer's ask-hint sanitizer."""
from __future__ import annotations
from deeptutor.services import mastery_hints
def test_sanitize_strips_list_markers_but_keeps_leading_text() -> None:
assert mastery_hints._sanitize("• Why does it converge?", "en") == "Why does it converge?"
assert mastery_hints._sanitize("-2 times -3 is positive?", "en") == "-2 times -3 is positive?"
def test_sanitize_keeps_apostrophes_and_inner_quotes() -> None:
assert (
mastery_hints._sanitize("What's the difference between a list and a tuple?", "en")
== "What's the difference between a list and a tuple?"
)
assert (
mastery_hints._sanitize('Why is "-1" not a root here?', "en")
== 'Why is "-1" not a root here?'
)
def test_sanitize_unwraps_quoted_or_fenced_question() -> None:
assert mastery_hints._sanitize('"Why does it converge?"', "en") == "Why does it converge?"
assert mastery_hints._sanitize("“为什么会收敛?”", "zh") == "为什么会收敛?"
assert mastery_hints._sanitize("```\nWhy does it converge?\n```", "en") == (
"Why does it converge?"
)
def test_sanitize_strips_list_marker_before_unwrapping_quotes() -> None:
assert mastery_hints._sanitize('- "Why does it converge?"', "en") == "Why does it converge?"
assert mastery_hints._sanitize('## • "Why does it converge?"', "en") == (
"Why does it converge?"
)