tests for markup property

This commit is contained in:
Will McGugan 2021-12-11 16:41:19 +00:00
parent 67f1c7ab29
commit 1c543b746d
2 changed files with 21 additions and 1 deletions

View File

@ -9,7 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Double print of progress bar in Jupyter
- Double print of progress bar in Jupyter https://github.com/willmcgugan/rich/issues/1737
### Added
- Added Text.markup property https://github.com/willmcgugan/rich/issues/1751
## [10.15.2] - 2021-12-02

View File

@ -715,3 +715,19 @@ def test_on():
assert text.get_style_at_offset(console, 0).meta == expected
assert text.get_style_at_offset(console, 1).meta == expected
assert text.get_style_at_offset(console, 2).meta == expected
def test_markup_property():
assert Text("").markup == ""
assert Text("foo").markup == "foo"
assert Text("foo", style="bold").markup == "[bold]foo[/bold]"
assert Text.from_markup("foo [red]bar[/red]").markup == "foo [red]bar[/red]"
assert (
Text.from_markup("foo [red]bar[/red]", style="bold").markup
== "[bold]foo [red]bar[/red][/bold]"
)
assert (
Text.from_markup("[bold]foo [italic]bar[/bold] baz[/italic]").markup
== "[bold]foo [italic]bar[/bold] baz[/italic]"
)
assert Text("[bold]foo").markup == "\\[bold]foo"