mirror of
https://github.com/Textualize/rich.git
synced 2025-08-04 01:58:24 +00:00
Add extra JSON highlighting tests
This commit is contained in:
parent
7ce9bcabcd
commit
93e584c47c
2 changed files with 17 additions and 0 deletions
|
@ -113,6 +113,22 @@ def test_highlight_json_with_indent():
|
|||
]
|
||||
|
||||
|
||||
def test_highlight_json_string_only():
|
||||
json_string = '"abc"'
|
||||
text = Text(json_string)
|
||||
highlighter = JSONHighlighter()
|
||||
highlighter.highlight(text)
|
||||
assert text.spans == [Span(0, 5, "json.str")]
|
||||
|
||||
|
||||
def test_highlight_json_empty_string_only():
|
||||
json_string = '""'
|
||||
text = Text(json_string)
|
||||
highlighter = JSONHighlighter()
|
||||
highlighter.highlight(text)
|
||||
assert text.spans == [Span(0, 2, "json.str")]
|
||||
|
||||
|
||||
def test_highlight_json_no_indent():
|
||||
json_string = json.dumps({"name": "apple", "count": 1}, indent=None)
|
||||
text = Text(json_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue