tests: add actionable error test for mismatched closing tag in markup

This commit is contained in:
Lesile Cai 2025-11-30 15:48:21 -05:00
parent 4d6d631a3d
commit 495481e600

View file

@ -0,0 +1,12 @@
import pytest
from rich.text import Text
from rich.errors import MarkupError
def test_invalid_markup_message_is_actionable_mismatched_close():
bad = "[bold]hello[/italic]" # mismatched closing tag should raise
with pytest.raises(MarkupError) as exc:
Text.from_markup(bad)
msg = str(exc.value).lower()
# keep the assertions flexible so they work with current Rich messaging
assert any(word in msg for word in ("invalid", "mismatch", "closing", "end tag"))