mirror of
https://github.com/Textualize/rich.git
synced 2025-12-23 07:08:35 +00:00
tests: add actionable error test for mismatched closing tag in markup
This commit is contained in:
parent
4d6d631a3d
commit
495481e600
1 changed files with 12 additions and 0 deletions
12
tests/test_markup_error_message.py
Normal file
12
tests/test_markup_error_message.py
Normal 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"))
|
||||
Loading…
Add table
Add a link
Reference in a new issue