mirror of https://github.com/Textualize/rich.git
Add extra JSON highlighting tests
This commit is contained in:
parent
7ce9bcabcd
commit
93e584c47c
|
@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Collapsed definitions for single-character spinners, to save memory and reduce import time.
|
||||
- Fix print_json indent type in __init__.py
|
||||
- Fix error when inspecting object defined in REPL https://github.com/Textualize/rich/pull/2037
|
||||
- Fix incorrect highlighting of non-indented JSON https://github.com/Textualize/rich/pull/2038
|
||||
|
||||
### Changed
|
||||
|
||||
|
|
|
@ -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…
Reference in New Issue