diff --git a/tests/test_markup_error_message.py b/tests/test_markup_error_message.py new file mode 100644 index 0000000000..56f873f697 --- /dev/null +++ b/tests/test_markup_error_message.py @@ -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"))